On Oct 30, 2008, at 8:21 PM, Adriano Brandão wrote:
I've created a method that gives me an NSMutableArray object with i
elements. Now I want to create another method that makes another
array, where each element is an NSMutableArray object that I got
from the previous method (in other words, I want a bi-dimensional
matrix). How can I do that using the Foundation Framework?
(1) You can do an array of arrays. An NSMutableArray instance is an
object like any other NSObject subclass and, thus, can be stuffed in
an NSMutableArray.
(2) You cod do it with a single NSMutableArray and do just a tiny bit
of math on to get an object at a particular cartesian coordinate.
(index = ((y * width) + x)), typically.
(3) You could build your own subclass of NSObject that manages an (id
*) iVar that you allocate to an appropriate size and then stuff
objects into it, as needed. Basic C pointer arithmetic is the key.
This also has the advantage of allowing holes easily enough. Just
make sure you retain as objects go in and release as objects are
removed.
(...) There are many other ways. It really depends on your needs.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden