Dynamically sized NSArray
Hi! This isn't exactly game related, but just a question about cocoa style using NSArray. I need to create an array with a number of objects of a single class that is determined at runtime. That number won't change throughout the run of the program, though, so I'm just using a plain NSArray. However, since NSArrays can't contain nil, what I'm doing now is mallocing a C array, initializing my NSArray with initWithObjects:count:, and then freeing the C array. Is there a more cocoa-ish way to do this or should I just forget about it and use NSMutableArray?
you can use [NSNull null] to represent nil and add that to the NSArray
"When you dream, there are no rules..."
If it were me, I'd initialize an NSMutableArray, add objects to it, then store it in an NSArray variable. This makes it semantically, though not physically, immutable.
Possibly Related Threads...
|Cannot find symbol in dynamically loaded library||Muskrat||4||3,893||
Jan 25, 2010 01:54 PM
Last Post: Muskrat