I compare my attempt at a Core Data caching challenge—storing fetched user data so the app can still display it after network failures—against Paul’s model solution. Differences covered include adding a merge policy for handling constraint conflicts, keeping ids as UUIDs, and placing MainActor.run inside the network fetch rather than after it...
In part three of my Core Data basics series, I show how to add a one-to-many relationship so each Garden can have multiple Plants. I cover converting the generated NSSet of related plants into a sorted array via a computed property, displaying the plants in a list in the garden detail view, and linking plant instances to a garden when creating sample data...
Part two of my series on Core Data basics, in which I convert a SwiftUI master/detail garden-list app from structs to Core Data. I walk through defining entities in the Xcode data model, generating editable NSManagedObject subclasses, setting up a DataController with NSPersistentContainer, and fetching and saving data with @FetchRequest. I defer one-to-many relationships to the next part, and I draw much of the code from Paul Hudson’s 100 Days of SwiftUI...
In the first part of my series on learning Core Data basics, I build a simple SwiftUI master/detail app that lists gardens and their plants using structs and arrays, as a starting point before converting it to Core Data in later parts. My code draws heavily on Paul Hudson’s 100 Days of SwiftUI course, with a GitHub link to the source...
Day 61 of the 100 Days of SwiftUI course presents a Core Data challenge that exposes gaps in my understanding, leading me to write out my current mental model of Core Data — object persistence, data models, code generation, and managed object contexts. Rather than push ahead, I plan to build a simple comparison of array-based storage versus Core Data before redoing the challenge...
My CoreData project from Day 53 of the 100 Days of SwiftUI course ran fine in the simulator but crashed in Xcode’s SwiftUI preview, which lacked a managed object context. I describe a workaround I found on the Hacking with Swift forums for supplying a context to the preview...