Tagline

Culture is roughly everything we do that chimpanzees don’t.

Take note, Core Data programmers, something stupid is afoot, and it’s even documented.

If you pass object URIs around like candy within your program for things like drag-and-drop or token fields or any other representation of your objects and then have to get the object back, use objectRegisteredForID instead of objectWithID.

When you use objectWithID you should note that it will never return nil to you on failure. It will create an invalid object and leave it astray in your managed object context preventing your users from saving their document unless you track it down and delete it. What they get instead is the following in the console.log:

 cannot find data for a temporary oid: 0xe293bf0 <x-coredata:///Tag/t20BCE87C-4867-40C4-8CFC-A1C0AD91EC73>

Yes, this presumes a problem with the URI, but the core shouldn’t make things worse in that case, IMO. However, there’s a method objectRegisteredForID that does what you’d expect and returns nil if the object could not be found, thus letting you do whatever needs to be done to clean things up.

Notae 2.0.2 should be out shortly and resolve an annoying issue with creating a lot of tags making documents unable to save due to this. This has apparently been in the code for a while and not surfaced until now. Sucky. Luckily, upgrades to 2.0 are free from 1.x, so upgrade already. Smiling

User login