Core Date Concept: NSFetchedResultsController vs. NSManagedObject objectsWithFetchRequest

寵の児 提交于 2019-12-25 14:24:37

问题


When do I use a NSFetchedResultsController in comparsion to the objectsWithFetchRequest method in NSManagedObject? Are there typical scenarios?


回答1:


objectsWithFetchRequest: (or executeFetchRequest:error:) just executes a fetch request and returns the result set.

A NSFetchedResultsController executes a fetch request and then monitors changes to the data store (or more precisely, changes to the managed object context). If objects are added/deleted/modified that cause the result set of the fetch request to change, it calls delegate functions to report the change.

A NSFetchedResultsController is in most cases used to populate a table view with the result of a fetch request, and automatically update the table view if objects are inserted, deleted or changed.



来源:https://stackoverflow.com/questions/13335775/core-date-concept-nsfetchedresultscontroller-vs-nsmanagedobject-objectswithfet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!