views:

35

answers:

2

Hello, 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?

Thanks for this awesome site!

+2  A: 

Use an NSArray or NSMutableArray, but you have to wrap your non-object values (CGPoints and integers) in wrapper objects. The integers can be wrapped in NSNumbers and the points can be wrapped in NSValues.

eman
A: 

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.

Perrako
THANKS, i just did more research on NSMutableArraay and figured everything out.
John