What data type to use for an ordered pairing of items?
I have a bunch of data (data that will remain constant) that I want to import in to my Cocoa app (OS X, iOS). This data is a pairing of "Title" and "Body" where the title might be "Really Cool Stuff" and body will be "Gosh, there's a lot of really cool stuff. Here's a big list...". There are several of these pairs, in an ordered list.
One data type that comes to mind is to create a aggregate object type with NSString *title;
and NSString *body;
properties, and then have an array of these. Is there another way such as an ordered dictionary.. (where title
is a unique key in to dictionary of body
)?
Last piece of the puzzle - I want this data to be in a persistent data store of some sort, the more automatic the better. Ideally, I want to use Core Da开发者_开发技巧ta. So an answer that addresses this in terms of Core Data is preferred. To complicate things, the data is being spit out of a perl script (would be tricky to rewrite in Objective-C/C)
You can design it based off of NSString as you alluded to. You'd then be able to insert the whole object into Core Data at some point in your program. In your Core Data design, you could just have one block containing the two attributes of the object.
精彩评论