On 11 Jun 2008, at 03:09, Jens Alfke wrote:
That way you won't run into the issue that NSArray objects can't
contain empty (nil) elements...
Another thing that is often overlooked by Cocoa newbies is that you
can add NSNull to NSArray objects (and other collection objects)
e.g
MyObj* a
NSArray objects can't contain empty (nil) elements...
NSPointerArray objects can if you really want an Objective-C interface.
And you might just want to implement this as a C array
They will also handle object memory management like an NSArray,
depending on how you initialise it.
However
It would be a lot more efficient to implement a two-dimensional m-by-n
array as a single NSArray with m*n elements. Then the object at
(row,column) is the object at index row*width+column. That's basically
how C implements multi-dimensional arrays.
You can't make this accessor a simple cate
If you do want to make use of some of the nice features of NSArray
that C arrays don't have, it is trivial to add a category to NSArray
that makes object retrieval easier. See http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_1.html
An example imp