Error creating a separate NSManagedObjectContext

前端 未结 2 1166
有刺的猬
有刺的猬 2021-01-25 08:32

Before getting into my issue, please have a look at this image.

\"enter

Here is th

2条回答
  •  暖寄归人
    2021-01-25 09:07

    The old data that was in your persistent store, and addressed with the original MOC, is still there, and will be retrieved when the second MOC does a fetch. They're both looking at the same persistent store. It's just that the second MOC also has new data fetched from your API.

    A synchronous network operation saving to Core Data will hang your app, and (for a large enough set of records) cause the system to kill your app, appearing to the user as a crash. Your client is wrong on that point, and needs to be educated.

    Break apart your logic for fetching, saving, and viewing. Your view that shows a particular date's records should just do that--which it can do, if it accepts a date and uses a predicate.

    Your 'cellForRowAtIndexPath' crash smells like a problem with a missing or misspelled identifier. What happens if you hard code a string instead of using 'record.name'?

提交回复
热议问题