Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 712
dontWatchMyProfile Avatar asked Dec 22 '22 02:12

dontWatchMyProfile


1 Answers

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.

like image 152
Marcus S. Zarra Avatar answered Jan 11 '23 23:01

Marcus S. Zarra