I’m working with a 2D array of ints as a map format for a game. The horizontal length of the map doesn’t change, but the vertical length can. Because of this, it seems that I should use the efficiency of C arrays for the actual data storage, and use an NSMutableArray for the container. However, I’m not sure how to go about doing this. Is it even possible to store a C array in an NSArray? I’ve tried various methods, but none seem to work.
Share
NSArray only stores objects. You could define a custom NSArray subclass with an int array as data storage and special methods to store ints, and then box them (that is, convert the ints into NSNumbers) for NSArray’s normal object interface — though that is way overly complicated for most purposes. But with plain NSArray, you’re stuck with objects.