The Case of the Mystery Body Recompute: Debugging SwiftUI, Core Data, and Ghost Body Passes

If you have spent enough time with SwiftUI, you have likely run into the dreaded ghost re-render: your view appears, nothing in your data model has visibly changed, but body fires twice. Recently, I embarked on a deep-dive investigation using LLDB, stack traces, and Self._printChanges() to uncover why a presented AlertContent view was evaluating its body twice upon Read more

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

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