NSFetchedResultsController returns duplicates (the same objectID and reference)

前端 未结 1 858

I\'m experiencing a weird behaviour with NSFetchedResultsController. It is new in iOS 10. Straight to the point: fetchedObjects contains duplicate objects.

相关标签:
1条回答
  • 2021-01-12 19:59

    I've come across similar problem today also. I noticed in my case the fetched objects on the FRC all had temporary IDs. These can be verified like so:

    fetchedResultsController.fetchedObjects[0].objectID.isTemporary
    

    To get around this problem in my App I explicitly request permanent object IDs for all the inserted objects before saving the context on which new data is imported/updated/synced:

    NSError *error;
    [bgContext obtainPermanentIDsForObjects:bgContext.insertedObjects.allObjects error:&error];
    
    0 讨论(0)
提交回复
热议问题