Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

committedValuesForKeys returns an empty dictionary on NSManaged object subclass

I'm using a NSManaged object subclass that was generated by the core data GUI tool in XCode.

NSLog'ing the object reveals that it's properly instantiated and holding values... But if I try to use something like this:

[generatedSubClass committedValuesForKeys:nil]

I get back an empty dictionary.

like image 227
Luke The Obscure Avatar asked Jan 22 '26 02:01

Luke The Obscure


1 Answers

The docs state that committedValuesForKeys

Returns a dictionary of the last fetched or saved values of the receiver for the properties specified by the given keys.

It follows that the object you are messaging is not the last fetched or saved.

Also, note that committedValuesForKeys is an instance method, not a class method.

Thus, not [managedObjectSubclass committedValuesForKeys:nil]
but [aManagedObject committedValuesForKeys:nil]

like image 93
Mundi Avatar answered Jan 23 '26 20:01

Mundi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!