/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
- World is a module
- World is aware of all modules.
- Modules aren't aware of World.
| import SwiftUI | |
| import PlaygroundSupport | |
| struct Desktop: View { | |
| var body: some View { | |
| ZStack { | |
| // Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG")) | |
| Color(UIColor.systemBlue) | |
| macOS() | |
| } |
| import Foundation | |
| public protocol CodingStrategy { | |
| associatedtype Converted | |
| associatedtype RawValue: Codable | |
| static func toRaw(_ value: Converted) throws -> RawValue | |
| static func toValue(_ raw: RawValue) throws -> Converted | |
| } |
| import Foundation | |
| public protocol DefaultValue { | |
| associatedtype Value: Codable | |
| static var value: Value { get } | |
| } | |
| @propertyWrapper | |
| public struct Default<Default: DefaultValue>: Codable { |
/// | World |
/// |------------------------------------------|
/// | Module A | Module B | Module C | Module D|
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"| @propertyWrapper | |
| struct Derived<Instance, Value> { | |
| var wrappedValue: Value { | |
| get { fatalError() } | |
| set { fatalError() } | |
| } | |
| private let getter: (Instance) -> Value | |
| private let setter: (Instance, Value) -> Void |
| @propertyWrapper | |
| struct Redraw<Value> { | |
| var wrappedValue: Value | |
| init(wrappedValue: Value) { | |
| self.wrappedValue = wrappedValue | |
| } | |
| static subscript<Instance: UIView>( | |
| _enclosingInstance instance: Instance, |
| // | |
| // ContentView.swift | |
| // DeleteMe | |
| // | |
| // Created by Chris Eidhof on 02.02.21. | |
| // | |
| import SwiftUI | |
| /* |
| // https://twitter.com/krzyzanowskim/status/1149607371204784129 | |
| extension TimeInterval { | |
| static func minutes(_ minutes: Int) -> TimeInterval { | |
| return TimeInterval(seconds(60) * TimeInterval(minutes)) | |
| } | |
| static func seconds(_ seconds: Int) -> TimeInterval { | |
| return TimeInterval(seconds) | |
| } |
| extension UIApplication { | |
| /// The top most view controller | |
| static var topMostViewController: UIViewController? { | |
| return UIApplication.shared.keyWindow?.rootViewController?.visibleViewController | |
| } | |
| } | |
| extension UIViewController { | |
| /// The visible view controller from a given view controller | |
| var visibleViewController: UIViewController? { |