CoreData: error: Mutating a managed object after it has been removed from its context

前端 未结 1 1518
慢半拍i
慢半拍i 2021-01-13 12:03

I built a simple app retrieving some JSON and storing the data inside Core Data.

Upon the initial install on the simulator or a device, all Core Data operations are

相关标签:
1条回答
  • 2021-01-13 12:39

    The error is interesting:

    <x-coredata:///Category/t4B10F995-A717-4DB8-9E87-8A1C079D45D42>

    Note the lower case t in front of the GUID. That means this object is new and has not been saved. Hence, unless you are throwing the unsaved managed object context away after each use, a fully valid strategy, you have a state mismatch.

    The easy way to solve your problem is to either issue more saves or operate in a child context which you throw away before each new fetch.

    0 讨论(0)
提交回复
热议问题