Working With Core Data

So I recently started an iPhone game that will be a memory clone, for fun and profit! I learned some things about CoreData that I would like to share, since there doesn’t seem to be a lot of information about what I ran into.

The major problem I’ve had so far was with special attribute names on an NSManagedObject. I did some searching and found one article online that documented this problem, where if you use one of apparently several reserved keywords for the name of an attribute, upon saving you get some weird error. I kept getting random errors like:

[NSCFView _isKindOfEntity:]: unrecognized selector sent to instance

The reason I was getting this was because I was using an attribute named “value”. Once I switched the name to “tileValue”, all the weird errors disappeared. So, Apple, what’s the deal? Which attributes names can and cannot be used?

But, aside from those frustrations, CoreData is pretty easy to use. Being most familiar with ActiveRecord, I don’t quite care for the verbosity associated with CoreData, but it is easily abstracted away. You can see my attempt at such a thing here. I’m currently building this class out in the project I’m working on, so all that is there right now are the header and implementation files. My goal is to have a separate project for this with it’s own test suite so that it would be easier for someone else to modify or extend it.

Posted by Steve on Saturday, February 13, 2010

Post a comment


(required, but not displayed)

(optional)