Re: Initialising NSMutableArray
Re: Initialising NSMutableArray
- Subject: Re: Initialising NSMutableArray
- From: "I. Savant" <email@hidden>
- Date: Mon, 13 Jul 2009 11:49:09 -0400
On Jul 13, 2009, at 11:44 AM, DKJ wrote:
I've subclassed an NSMutableArray, and I want it to be initialised
with some objects already in place. So I did this:
...
I suspect I'm missing something simple here.
Yes:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/nsmutablearray_Class/Reference/Reference.html
"NSArray and NSMutableArray are part of a class cluster, so arrays are
not actual instances of the NSArray or NSMutableArray classes but of
one of their private subclasses."
Subclassing is fraught with many angry, fire-breathing, treasure-
grubbing dragons and as such is *not* recommended. Especially if
you're only trying to get a mutable array populated with a single
object.
What's wrong with [[NSMutableArray arrayWithObject:[[MyClass alloc]
init]]; ?
Create a convenience method somewhere in your project such as -
mutableArrayWithMyClass that contains the above and you're done. No
dragons.
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden