Re: Multidimensiaon Arrays in Cocoa
Re: Multidimensiaon Arrays in Cocoa
- Subject: Re: Multidimensiaon Arrays in Cocoa
- From: John Hörnkvist <email@hidden>
- Date: Sun, 23 Sep 2001 14:02:09 +0200
On Sunday, September 23, 2001, at 01:35 PM, email@hidden wrote:
Am I missing something or are there no multidimensional arrays in
Cocoa's NSArray? What do we do, just implement them the old fashioned
way with Objective-C?
You can implement it with NSArray.
But multidimensional arrays are not quite as easy to handle in a single
class as arrays; their implementation is far more application dependent.
Eg, a matrix brings in the assumption that all rows have the same size.
Your matrix class should be able to handle that. A matrix is often quite
sparse, and very large, so the class should handle that.
On the other hand, if your 2D array is representing something else, then
you may want different row lengths, and the ability to dynamically grow
the rows.
Each case is reasonably easy to implement on top of a Foundation object
(and some as C arrays). However, Foundation couldn't support all of them
without becoming bloated.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com