| extension StringProtocol { | |
| subscript(_ offset: Int) -> String.Element { | |
| if offset >= 0 { | |
| self[index(startIndex, offsetBy: offset)] | |
| } else { | |
| self[index(endIndex, offsetBy: offset)] | |
| } | |
| } | |
| import SwiftUI | |
| private struct OnLoad: ViewModifier { | |
| let action: () -> Void | |
| @State private var loaded = false | |
| func body(content: Content) -> some View { | |
| content.onAppear { | |
| if !loaded { | |
| loaded = true |
| import SwiftUI | |
| private struct OnFirstAppear: ViewModifier { | |
| let perform: () -> Void | |
| @State private var firstTime = true | |
| func body(content: Content) -> some View { | |
| content.onAppear { | |
| if firstTime { |
| import Foundation | |
| import HealthKit | |
| struct WorkoutSplit: Hashable { | |
| let label: String | |
| let distance: HKQuantity | |
| let duration: TimeInterval | |
| } | |
| extension WorkoutSplit { |
| import Foundation | |
| import HealthKit | |
| struct WorkoutSplit: Hashable { | |
| let label: String | |
| let distance: HKQuantity | |
| let duration: TimeInterval | |
| } | |
| extension WorkoutSplit { |
| import UIKit | |
| extension UIView { | |
| /* Usage Example | |
| * bgView.addBottomRoundedEdge(desiredCurve: 1.5) | |
| */ | |
| func addBottomRoundedEdge(desiredCurve: CGFloat?) { |
| // | |
| // ContentSizePagingCollectionDelegate.swift | |
| // CardsCarousel | |
| // | |
| // Created by Daniel Carlos Souza Carvalho on 2/20/21. | |
| // | |
| import UIKit | |
| /// Horizontal paging for collections based on the content size |
If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).
You can do this in recent versions of Xcode by setting a configuration default.
From a terminal, just type this command and press Enter:
defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).
You can do this in recent versions of Xcode by setting a configuration default.
From a terminal, just type this command and press Enter:
defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
