Clearing a context in Core Data: reset vs deleting registered objects?

前端 未结 1 567
予麋鹿
予麋鹿 2021-02-15 14:26

I was looking for posts regarding to this, but I don\'t fully understand... What is the difference between:

[context reset];

and:



        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-15 15:13

    Using reset puts the managed object context back to the state it was in when you first created it-- before you had performed any fetches, created any new objects, etc. If you have any managed objects in memory that were fetched from this context, they're now unusable. Using reset does not affect the persistent store file. All instances still exist afterward, they're just not in memory. They can be fetched again.

    Using deleteObject removes the object from the persistent store. It does not exist any more. It can't be fetched anymore because it doesn't exist.

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