ioscore-datauicollectionviewnsmanagedobjectmodel

The best way to store "Item-ItemDetails" in CoreData


As 99% of iOS apps, mine has a main screen with a long list of items, and when a user taps one, he sees item details. Pretty much straightforward. Let's say, to render the first screen I need titles and images. And for the second one - a large html. All the data is stored persistently in CoreData.

I want the list (UICollectionView) to be as fast as possible. So I can't load html-s until a user is on the details screen.

How can it be implemented? Should I create two NSManagedObject classes: Item and ItemDetails? Does CoreData load everything lazily?


Solution

  • Splitting it into Item and ItemDetails is a good approach.

    I'd check first, though, if it's really a performance problem. You want to be sure to understand how setting a batch size affects fetch performance. The Accessing Data and Performance chapters in our Core Data book goes into all the details.