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 category method on NSArray, because it needs to know the width (and categories can't add instance variables.) But it would be very easy to make your own class that had an NSArray and the width as instance variables.

And you might just want to implement this as a C array, if the height and width are hard-coded. You just have to remember to retain objects you store into the array and release them when they're removed or replaced. That way you won't run into the issue that NSArray objects can't contain empty (nil) elements...

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to