What's the difference between -existingObjectWithID:error: and –objectWithID: ?
views:
33answers:
2
+2
A:
I believe existingObjectWithID:error:
returns an instance only if it has already been registered with the receiving context. objectWithID:
may return a fault for an object that has not yet been registered (pulled into) the receiving context.
Barry Wark
2010-06-09 19:48:07
A:
objectWithID: assumes the object exists so if you give it a bad ID it will throw an exception when you attempt to access a property on the returned entity. Also, this method always returns an entity.
existingObjectWithID:error: will return an object if it exists and nil if it does not. If there was an error it will populate the error pointer.
Marcus S. Zarra
2010-06-09 21:21:08
I tried objectWithID: It does not throw any exception. See http://stackoverflow.com/questions/3013194/must-i-explicitely-enable-exceptions-in-xcode
dontWatchMyProfile
2010-06-10 09:53:54