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

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


  • Follow-Ups:
    • Re: Initialising NSMutableArray
      • From: Quincey Morris <email@hidden>
    • Re: Initialising NSMutableArray
      • From: Gideon King <email@hidden>
References: 
 >Initialising NSMutableArray (From: DKJ <email@hidden>)

  • Prev by Date: [iPhone] Network connection between 2 iPhones
  • Next by Date: Re: [iPhone] Network connection between 2 iPhones
  • Previous by thread: Initialising NSMutableArray
  • Next by thread: Re: Initialising NSMutableArray
  • Index(es):
    • Date
    • Thread