开发者

NSManagedObjectContext returns YES for hasChanges when there are none

开发者 https://www.devze.com 2022-12-28 06:51 出处:网络
I created a separate NSManagedObjectContext on a separate thread to perform some store maintenance. However, I have noticed that the context returns YES for hasChanges as soon as 开发者_开发问答a mana

I created a separate NSManagedObjectContext on a separate thread to perform some store maintenance. However, I have noticed that the context returns YES for hasChanges as soon as 开发者_开发问答a managed object in it is even referenced e.g.

NSString *name = managedObject.name;

This context is created and used exclusively in 1 method. Why is it returning has changes, when there there are none?


That ks difficult to answer without seeing the code. Perhaps your object has a -awakeFromFetch call that touches a property or something else. Normally there should be no changes from just fetching an object unless you are doing something to that object either in the awakeFromFetch or somewhere else in your code.

update

Before the save, grab the deleted array, updated array and inserted array and take a peek at them. That will give you a hint as to what is going on.

0

精彩评论

暂无评论...
验证码 换一张
取 消