• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Two dimensional array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two dimensional array


  • Subject: Re: Two dimensional array
  • From: "Robert P. Tito" <email@hidden>
  • Date: Fri, 14 Nov 2003 18:38:32 +0100

Sheesh,


Whatever happend to char/int/float *arrayexample[ ] [ ];



On 14-11-2003 17:37, "Roarke Lynch" <email@hidden> wrote:

> On Nov 13, 2003, at 10:05 PM, Prachi Gauriar wrote:
>
>> NSArray *root;
>> root = [[NSArray alloc] initWithObjects:
>> [[NSArray alloc] initWithObjects:
>> [NSNumber numberWithDouble:1.1],
>> [NSNumber numberWithDouble:2.2],
>> [NSNumber numberWithDouble:3.3],
>> [NSNumber numberWithDouble:4.4],
>> [NSNumber numberWithDouble:5.5],
>> nil],
>> [[NSArray alloc] initWithObjects:
>> [NSNumber numberWithDouble:10.10],
>> [NSNumber numberWithDouble:9.9],
>> [NSNumber numberWithDouble:8.8],
>> [NSNumber numberWithDouble:7.7],
>> [NSNumber numberWithDouble:6.6],
>> nil],
>> ...
>> nil ];
>
> your nested arrays should be created with the convince method [NSArray
> arrayWithObjects:] not alloc'ed and init'ed. Both nested arrays have a
> retain count of 2 (1 for the alloc, 1 for the retain that the root
> array calls when the nested array is added as a member). I.e. use:
>
> NSArray * root = [[NSArray alloc] initWithObjects:
> [NSArray arrayWithObjects:@"One", @"Two", @"Three", ni],
> [NSArray arrayWithObjects:@"Three", @"Four", @"Five", nil], nil];
>
> But even beyond that, If you really want to have a mulidimensional
> array I would suggest making your own class. You could run into a lot
> of problems doing it this way, i.e. objects changing rows or columns by
> adding or removing members. I would make a class that manages additions
> and removals of items by marking an unused address w/ an NSNull object.
>
> Roarke Lynch
> -------------------------------
> email@hidden
> _______________________________________________
> 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.
>






Rob Tito
_______________________________________________
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.

References: 
 >Re: Two dimensional array (From: Roarke Lynch <email@hidden>)

  • Prev by Date: How can I display invisible glyphs in a Text Edit field?
  • Next by Date: Re: Oracle support in 10.2 client?
  • Previous by thread: Re: Two dimensional array
  • Next by thread: Re: Two dimensional array
  • Index(es):
    • Date
    • Thread