Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: How to create a matrix using Foundation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a matrix using Foundation?



On Oct 30, 2008, at 8:21 PM, Adriano Brandão wrote:
I've created a method that gives me an NSMutableArray object with i elements. Now I want to create another method that makes another array, where each element is an NSMutableArray object that I got from the previous method (in other words, I want a bi-dimensional matrix). How can I do that using the Foundation Framework?

(1) You can do an array of arrays. An NSMutableArray instance is an object like any other NSObject subclass and, thus, can be stuffed in an NSMutableArray.


(2) You cod do it with a single NSMutableArray and do just a tiny bit of math on to get an object at a particular cartesian coordinate. (index = ((y * width) + x)), typically.

(3) You could build your own subclass of NSObject that manages an (id *) iVar that you allocate to an appropriate size and then stuff objects into it, as needed. Basic C pointer arithmetic is the key. This also has the advantage of allowing holes easily enough. Just make sure you retain as objects go in and release as objects are removed.

(...) There are many other ways.   It really depends on your needs.

b.bum

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

This email sent to email@hidden

References: 
 >How to create a matrix using Foundation? (From: Adriano Brandão <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.