SwiftUI, Core Data and API (JSON)

Hello,


I'm looking for a tutorial in SwiftUI with Core Data. I'll build an app with an online and offline options. So the app needs to download data from an API service. Load the data into the Core Data, then the app needs to read the data from core Data. The user needs also an option to synchronize the data back.


Does somebody know where I can find a tutorial for this?


Kind Regards,


Kitty

Post not yet marked as solved Up vote post of Silty Down vote post of Silty
3.8k views

Replies

Paul Hudson provides a nice overview of getting CoreData integrated with SwiftUI here: https://www.hackingwithswift.com/quick-start/swiftui/introduction-to-using-core-data-with-swiftui — beyond that, you'll want to look at the JSONEncoder type and Swift's Encodable and Decodable protocols. I don't think there's a tutorial that will walk you through everything you want, though; at least, not from a SwiftUI perspective.

Try "Practical Core Data" - Donny Wals. Ch7 on remote synchronisation uses JSON and decodable to import/sync into core data.