Something I'm trying to figure out for a while:
A Core Data App I'm working on has a parent Entity with several one-to-many relationships to other Entities. It's structure would look like this:
CarBrand > Dealers > Cars available CarBrand > Factory > Models
Let's assume this app doesn't contain any network calls, everything is just entered and stored locally on-device (as the above structure is just a sample).
I'm only fetiching data from CoreData when the app launches. Once I add a new dealer, car, factory... these automatically appear in the list of available Cars thanks to how SwiftUI works. However, I've seen other apps that would fetch data from the database on every single view, so in the example above: CarBrandList: initial Fetch Request > DealersList: Fetch Request > Available Cars List: Fetch Request.
Does that give me any benefits like performancewise? Or would it even put more workload on the app?
@Benji is trying to load some CoreData concepts into his longterm memory banks:
These are concepts that database programmers have always battled. Access vs Performance. Fresh data vs Stale data.
Please note: I don't back up my observations with hard scientific proof.
But in my readings and education journey, I've settled on a comfort level that unless I'm working with tons of data, millions of records, the performance of chips in iPhones and iPads will never be challenged by CoreData lookups. Also, CoreData was written by boffins who baked in caches and fetch optimizations, leaving you to focus more on the business at hand.
Have you bought Donny Walls' book?
See -> Practical Core Data
It's your fault!
In Chapter 4, he discusses some of your points. Pay particular attention to
10/10 Would recommend. 👍🏼
CoreData is vigilent in keeping its object graph optimized when your application is in play. So while you may load a number of
See -> It's your fault!
Xcode and Instruments
Finally, tell us how you're using Xcode's
Please share how
Watch -> WWDC 22 Instruments and CoreData
Please share your CoreData results with us!
Back when I bought it, it felt like it was way above my head, so yeah I should take another read these days. Good point.
Uhm...to be honest, never got into that. I'll put that onto my list, too.
There is so much more to learn about CoreData, but there are only very few tutorials using CoreData AND SwiftUI that go deep enough. With no experience in UIKit the older tutorials available are quite hard for me personally to get into.
Too bad Mark Moeykens book is delayed.
I'll try to get into the things you mentioned sooner rather than later and report back where that led me!
For now: Thanks again!
I'll keep this thing open for a few more days as the above may lead to more questions!
SPONSORED From March 20th to 26th, you can join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.