|
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? Many thanks! |
|
@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. 👍🏼 Apple's documentation:
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! Brief excerpt:
Xcode and InstrumentsFinally, tell us how you're using Xcode's Please share how Watch -> WWDC 22 Instruments and CoreData Keep coding!Please share your CoreData results with us! |
|
Thanks @Obelix!
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 Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.