Search code examples
iosobjective-cnsarraynsdictionary

Objective-C Storing Information


In an iPhone app, the User can create Items - each Item needs to have a CGPoint, NSString and a few integers with information about it. The User can keep adding these Items.

How can I store all these variables for each of the Items and programmatically keep adding them to a list or array or something?

I tried using a struct array but it can't hold a NSString. I tried using a NSMutableAray of a custom class, but I can only add them if I make and name them by hand.

Any suggestions, ideas? Could I use a NSDictionary?


Solution

  • Create an Item class, that contains your CGPoint, NSString, and any other piece of info you want. Then, make an NSMutableArray and add new instances of your Item class as you see fit. NSDictionary and NSArray aren't really what you're looking for.