I am building an iPhone application that needs to store some sort of matrix or vector data in core data. For some unknown reason, the iPhone SDK does not include any kind of matrix data structure in its foundation classes, so I built my own data structure which uses an NSMutableArray
of NSMutableArrays
to store the data. So far so good.
I'd like to store this data structure in my core data store, and I've read about using transformable attributes to store non-standard structures. When I try to store the data structure, I get the following error: [FCMatrix encodeWithCoder:]: unrecognized selector sent to instance
The code that I am running is as follows, essentially just setting the attribute in my entity:
[collection setMatrix:matrix];
My assumption at this point is that since matrix is a transformable attribute, and my FCMatrix class is a custom object (subclassed from NSObject), I need to implement the method encodeWithCoder
in my data structure class so that Core Data can properly encode, store, and then decode the data to recreate my data structure. Can anyone explain the best way to do this?
Another idea - I'd like to know what you think - is to rebuilt my FCMatrix class to be subclassed from NSMutableArray. If NSMutableArray could be transformable, then I would be set.
Alternately, I am convinced that this is way too much work and that there has to be an easier way to do this. Does anyone have any experience storing matrix data in core data?