views:

33

answers:

2

What's the difference between -existingObjectWithID:error: and –objectWithID: ?

+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
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
I tried objectWithID: It does not throw any exception. See http://stackoverflow.com/questions/3013194/must-i-explicitely-enable-exceptions-in-xcode
dontWatchMyProfile