Re: Two dimensional array
Re: Two dimensional array
- Subject: Re: Two dimensional array
- From: Ben Dougall <email@hidden>
- Date: Thu, 13 Nov 2003 23:08:38 +0000
On Thursday, November 13, 2003, at 10:10 pm, Jay Rimalrick wrote:
How do you create a two dimensional static array in objective c?
in c++ I would do this
myArray[5][5] = {a,b,c,d,e},
{f,g,h,i,j},
{k,l,m,n,o},
{p,q,r,s,t}
{u,v,w,x,y};
how can I do this in objective c and how can I access the members?
a more accurate description of the construction above would be 5 single
dimension arrays in a single dimension array. 2d arrays are just arrays
in an array.
so:
NSArray *root, *one, *two, *three, *four, *five;
one = [[NSArray alloc] initWithObjects: @"a", @"b", @"c", @"d", @"e",
nil];
two = [[NSArray alloc] initWithObjects: @"f", @"g", @"h", @"i", @"j",
nil];
....
root = [[NSArray alloc] initWithObjects: one, two, three, four, five,
nil];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.