Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
与 NSManagedObject中的objectsWithFetchRequest方法相比,何时使用NSFetchedResultsController?有没有典型的场景?
objectsWithFetchRequest:(或executeFetchRequest:error:)只是执行一个获取请求并返回结果集。
objectsWithFetchRequest:
executeFetchRequest:error:
ANSFetchedResultsController执行获取请求,然后监视对数据存储的更改(或更准确地说,对托管对象上下文的更改)。如果添加/删除/修改导致获取请求的结果集更改的对象,它会调用委托函数来报告更改。
NSFetchedResultsController
ANSFetchedResultsController在大多数情况下用于使用获取请求的结果填充表视图,并在插入、删除或更改对象时自动更新表视图。