Dynamically filtering @FetchRequest with SwiftUI

Update 30/6/2022: I realised we shouldn’t be initing NSPredicate objects inside body so need a new approach. I was reading Paul Hudson’s article Dynamically filtering @FetchRequest with SwiftUI and thought I would share an improvement for declaring the singers @FetchRequest property that supports a dynamic predicate for filtering: FilteredList.swift ContentView.swift

MKMapSnapshotter initWithOptions nullability

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 that capture an image of the current user’s country”, thus Read more…

New Way to Override NSManagedObject Properties

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, copy) NSString *name; @end Department.m @interface Department (DynamicAccessors) – (NSString Read more…

Common Init for a UIViewController Subclass

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 as follows: – (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super Read more…