views:

23

answers:

1

Hi All,

Core data provides the method "executeFetchRequest" in NSManagedObjectContext class, which we can use to fetch data from tables and use it whatever the way need to.

Now there is another way by using NSFetchedResultsController and providing it to UITableView to fetch and data from tables.

My questions are now:

  • Which way is faster?, I mean performance wise, which one is the best?

  • Is NSFetchedResultsController is only used with UITableViews?

  • What are the Pros and Cons of the NSFetchedResultsController.

  • And last thing, "Why we use NSFetchedResultsController", what thing makes it better than any other way.

+3  A: 

And last thing, "Why we use NSFetchedResultsController", what thing makes it better than any other way.

The FRC class is designed to automatically handle all the overhead associated with providing complex and dynamic data for tables.

If all you have is a simple, one section table whose data never changes, then an FRC gives you not advantage. You just do one fetch and you are done. However, if the data is being changed either in UI (user rearranges, deletes or adds) or by code (e.g data is being updated from a server) the FRC provides the mechanisms for handling all that constant change and making sure the table accurately reflects those changes.

Which way is faster?, I mean performance wise, which one is the best?

There is no major performance difference in using either a fetch or FRC because they both use the same fetch mechanism to get data from the persistent store. If you have complex dynamic data then it is faster to use the FRC than to duplicate its functionality by hand.

What are the Pros and Cons of the NSFetchedResultsController.

See above.

Is NSFetchedResultsController is only used with UITableViews?

Yes, its really is only useful with tables.

TechZen
It perfectly make sense, all the extra overhead is already taken care of. Like in my case, records are updates frequently by a server. So any moment UI can be updated, previously i was using fetch request, and to update UI i was using NSNotifications, but FRC is giving such ease now, changes are automatically reflected in Table Views.
Ansari
So, Thanks a lot .... :)
Ansari