开发者

Using NSFetchedResultsController outside of a UITableViewController

开发者 https://www.devze.com 2023-02-19 20:49 出处:网络
Would it be wrong to use NSFetchedResultsController outside of a UITableViewC开发者_Go百科ontroller, since non-UITableView controllers would be unable to implement the NSFetchedResultsControllerDelega

Would it be wrong to use NSFetchedResultsController outside of a UITableViewC开发者_Go百科ontroller, since non-UITableView controllers would be unable to implement the NSFetchedResultsControllerDelegate protocol?


There is no particular reason you can't use a NSFetchedResults controller without a table. You can define any arbitrary class to implement the NSFetchedResultsControllerDelegate protocol.

However, there is seldom any particular reason why you would want to do so. The FRC is designed to fetch and order data for a table. It tracks section names and the like as well. Other controls don't really need that ordering or that information.

If you want a controller to watch the managedObject context for changes like an FRC, then you should register the controller for context's various notifications. Then the controller can update the view as needed just as an FRC does for a tableview.

0

精彩评论

暂无评论...
验证码 换一张
取 消