Objective-C/iPhone beginner here…looking for a shove in the right direction.
I need to create an array that will later be stored using CoreData. In reality this is best described as an n x m matrix. Each row being a record. All data is integer.
something like this:
struct record
{
int index;
int mode;
int counter;
};
struct record database[20];
I am paraphrasing here. This isn’t a database application. The matrix in question holds the data necessary to run a state machine. But, you get the idea. A bunch of rows of integers.
What’s the best O-C approach to this, considering that I need to save the matrix to the file system.
Can I use an NSArray of structs? (I don’t think NSArray likes non-object types).
NSArray of NSArray’s?
NSArray of NSDictionary?
Thank you,
-Martin
You are correct. NSArray only accepts objects that inherit from NSObject. Because of this, you can use an array of NSArrays, or convert your struct to an object that inherits from NSObject and store that in the array instead. The bonus for this is that you (may?) be able to use an NSManagedObject which you could then integrate nicely with core data.
Bear in mind that Core Data is an object graph, not a database. Because of this, you may want to start from that side, instead of designing your objects then trying to fit them into a relational database.