Notto Holden
Notto Holden

Reputation: 71

Core Data made easy with using of Arrays

browsing in some core data pages online i found a tutorial that use an interesting technique, i never seen nor used it before, but actually looks pretty smart.

Instead of working with long methods, with FRC, and so on, they place the results of the fetchResultController in an array, so they can use it to do all the work.

here is the link. http://www.appcoda.com/introduction-to-core-data/

What do you think are the errors of using this approach? it's a valid one?

Upvotes: 2

Views: 110

Answers (1)

Kevin
Kevin

Reputation: 17536

It works, but it completely defeats the purpose of the NSFetchedResultsController. The FRC is meant to fetch objects from Core Data in batches, which is much more efficient. If you create an array from all the fetched objects, you will load all those objects into memory at once (if you have a gazillion entities, then this will be a problem). Also if any of your data ever changes (you get notified by the delegate), then you will need to perform the fetch again, then recreate the array yourself.

Upvotes: 1

Related Questions