Update results of NSFetchedResultsController without a new fetch

前端 未结 2 1553
误落风尘
误落风尘 2020-12-19 05:41

I\'m working on an application that holds its data in an external MySQL server, but caches it locally using Core Data for better response times. Basically, what I\'d like to

2条回答
  •  天涯浪人
    2020-12-19 06:25

    just have your problem and yes apparently using notifications is the unique way you can make a tableview refresh when the table used a nsfetchedresults controller.

    like in the core databooks sample:
    step1: add an observer to the NSNotificationCenter for the notification NSManagedObjectContextDidSaveNotification
    step2: save your context (the notification trigger to your selector)
    step3: in your selector method: merge the changes in the context using the method mergeChangesFromContextDidSaveNotification
    step4: remove the observer from the notification center.

    Personally I would like to bypass the notification certer and only tell the context refresh yourself dammit :)

提交回复
热议问题