ios - What collection class should I use? -


at moment, iphone app uses nsmutablearrays hold onto nsstrings. have more information want associate each entry in each array. example, had 1 thing put in array1[0], string. now, however, along string want associate string , integer. guess like:

old: [string]

new [string, string, integer]

i thinking of using dictionary i'm not sure if it's right. advice?

the elements in nsarray dictionaries, c structs, or objective-c objects.

a dictionary works, can cumbersome if you’re storing primitive data type values (need boxed, e.g. nsnumber) or there’s potential extending data in deeper levels (dictionary containing dictionary containing dictionary). also, dictionary objects not implicitly typed.

a c struct works needs boxing, , don’t benefit cocoa collection semantics regard memory management — have on own. also, there’s no implicit support copy/retain semantics struct members.

i declare objective-c class aggregate data types stored in collections such nsarray. in case, like

@interface mydata : nsobject @property (nonatomic, copy) nsstring *firststring; @property (nonatomic, copy) nsstring *secondstring; @property (assign) nsinteger integer; @end 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -