• 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: multidimensional arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multidimensional arrays


  • Subject: Re: multidimensional arrays
  • From: Thomas Davie <email@hidden>
  • Date: Mon, 14 Mar 2005 19:17:03 +0000


On Mar 14, 2005, at 7:03 PM, Serge Meynard wrote:

Hi All,

I've run into a situation where it would be great to have a multidimensional NSArray or NSMutableArray. Is there such a class? If not, any suggestions on the most elegant solution?

Thanks,
Daniel

It's actually one of the major annoyances (to me anyway) of working in pure Obj-C code on this project: there is no direct support for multi-dimensional arrays, or even static arrays of PODs. Implementing an NSArray of NSArrays just feels ugly, and the syntax to access items is awful. And having to revert to good old-fashioned C-style indexing (e.g. myArray[y * rowLength + x]) is annoying. Since my arrays are part of larger objects, I end up writing an accessor that looks like [self itemAt:x:y]. I miss the simpler myArray[x][y] syntax of C++, and the STL containers, and the temptation is always there to start mixing the two languages; but I swore to myself I'd write this app in pure Obj-C so I could honestly know what it's like.
All I can say is:

#define x<y> [x objectAtIndex:y]

Bob

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >multidimensional arrays (From: Daniel Child <email@hidden>)
 >Re: multidimensional arrays (From: Serge Meynard <email@hidden>)

  • Prev by Date: Re: Obtaining the NSGraphicsContext for custom NSView
  • Next by Date: (Followup Question) Makes int from pointer without cast
  • Previous by thread: Re: multidimensional arrays
  • Next by thread: Re: multidimensional arrays
  • Index(es):
    • Date
    • Thread