• 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
Two Dimensional NSArrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Two Dimensional NSArrays


  • Subject: Two Dimensional NSArrays
  • From: John Stringham <email@hidden>
  • Date: Sat, 22 Sep 2001 16:34:04 -0400

Hi all,

I've run into a problem with a bit of code of mine that creates a two-dimensional array of objects. The array is full of objects that are quite simple - they're just NSObject subclasses with a few normal C variables and a number of functions. Currently, I have the array set up like so:

MyObject arrayOfMyObjects[10][10];

As of right now I have to go through all of the objects, allocate memory and initialize them. Also, writing this array to file has proven to be a bit tedious (iterating through the array and having each object pass a data record back to be recorded to file.)

That said, my questions are as follows: If I were to use an NSArray, is there a simple/elegant way to create a two dimensional array? With the current documentation all I can see is that you would have to go through each item and add an array of another 10 items to it. Also, are these items automatically initialized and released? And finally, how would I go about getting the -writeToFile: message to work properly with the array (would making MyObject a subclass of NSData work?)

Much thanks,
-John Stringham


  • Follow-Ups:
    • Re: Two Dimensional NSArrays
      • From: Ondra Cada <email@hidden>
References: 
 >Terminal TextView.... (From: Peter <email@hidden>)

  • Prev by Date: Terminal TextView....
  • Next by Date: Re: static typing (Learning Cocoa Chapter 13)
  • Previous by thread: Terminal TextView....
  • Next by thread: Re: Two Dimensional NSArrays
  • Index(es):
    • Date
    • Thread