SwiftUI: AppStorage with Dynamic Key
If we want to use @AppStorage but with a dynamic key passed to the View we can do this: DynamicKeyApp.swift ContentView.swift
If we want to use @AppStorage but with a dynamic key passed to the View we can do this: DynamicKeyApp.swift ContentView.swift
Here is one way to implement @AppStorage using a custom UserDefaults suite by way of the defaultAppStorage View modifier and a class extension. GroupDefaultsTestApp.swift ContentView.swift
MKMapSnapshotter has the following constructor (within NS_ASSUME_NONNULL_BEGIN): – (instancetype)initWithOptions:(MKMapSnapshotOptions *)options NS_DESIGNATED_INITIALIZER; Which means an options param must be supplied. However the documentation contradicts this, stating “If you specify nil for this property, the snapshotter uses a set of default options Read more
Always wondered why NSFetchedResultsChangeUpdate is so buggy? The reason is Apple don’t actually use it in their own apps. Instead, what they do is have a UITableViewCell subclass with a custom property setter for the object where they add KVO Read more
There is a new, yet not very well-known way to override NSManagedObject properties without needing to manually call KVO methods willChangeValueForKey etc. This is achieved using dynamic accessors prefixed with managedObjectOriginal as follows: Department.h @interface Department : NSManagedObject @property (nullable, nonatomic, Read more
When creating a UIViewController subclass, e.g. in a framework, which you require to support being created from both storyboards and code, it is useful to implement initialisation which works for both. That can be achieved with a common init routine Read more
By default, screenshots save to the Desktop which isn’t ideal. With this terminal command you can change the folder, e.g. to the Pictures folder: defaults write com.apple.screencapture location ~/Pictures To remove the setting and go back to the default do: Read more
Like many others I’ve been unhappy with the lack of Mac hardware lately so thought I’d revisit the world of osx86 after many years. There seems to be many more people involved in the scene now including some excellent how-to Read more
Here is a modern way to register user defaults. It uses dispatch_once to ensure the registration only happens once and performs it lazily on the first access. Keeps your defaults all on the one place. Also it is implemented as Read more
Sometimes when compiling more sophisticated iOS projects you need the IOKit headers which were removed from the iOS SDK a few versions ago. A simple workaround is to copy them from the Mac OS SDK to the iOS SDK with these commands: sudo Read more