NSManagedObject's hasChanges is true while changedValues is empty

后端 未结 5 825
心在旅途
心在旅途 2021-02-12 22:41

I am trying to observe individual NSManagedObject changes on NSManagedObjectContextWillSaveNotification:

- (void)managedObjectContextWi         


        
5条回答
  •  广开言路
    2021-02-12 23:26

    Do you have any transient attributes on your entity? I am seeing the behavior you describe, and I've written some test code that shows that modifying a transient attribute causes hasChanges to return true, while changedValues is empty.

    You can avoid this behavior by using setPrimitiveValue:forKey: to modify your transient attribute or the equivalent method generated by Core Data (setPrimitiveFoo: for an attribute named foo). You could also implement the transient attribute's setter to do this for you.

提交回复
热议问题