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

Re: [NSMutableArray array]


  • Subject: Re: [NSMutableArray array]
  • From: Dave DeLong <email@hidden>
  • Date: Thu, 08 Apr 2010 08:25:17 -0600

Yes, that is safe to use.  It's safe to use because classes are really just special objects, which means they get all the class method inheritance that instances get with instance methods.  This will work in every case where the implementors have used:

[[[self alloc] init] autorelease]  //this will instantiate a new instance of whatever class invokes this method

Instead of

[[[MyClass alloc] init] autorelease]  //this will instantiate a new instance of MyClass, regardless of which class invoked this method

Just like in instance methods, class methods have an implicit "self" variable that refers to the Class itself.

Beyond that, NSMutableArray and NSArray are really just the same class (NSCFArray, usually), with mutability determined by an internal flag.

Cheers,

Dave

On Apr 8, 2010, at 8:20 AM, Patrick M. Rutkowski wrote:

> Is is safe to do [NSMutableArray array], even with the "array" class
> method is actually declared as +[NSArray array]. In other words, is it
> safe to call a super-class' class method.
>
> If not, why?
>
> If so, why? And also, is it generally safe in _all_ cases, or only
> just when specifically crafted to work?
>
> Many thanks,
> -Patrick

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

_______________________________________________

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: [NSMutableArray array]
      • From: "Patrick M. Rutkowski" <email@hidden>
References: 
 >[NSMutableArray array] (From: "Patrick M. Rutkowski" <email@hidden>)

  • Prev by Date: How to force a 32-bit/64-bit universal app to start in 32-bit mode on Leopard?
  • Next by Date: Configuring NSPrinterInfo to print on a labeled paper.
  • Previous by thread: [NSMutableArray array]
  • Next by thread: Re: [NSMutableArray array]
  • Index(es):
    • Date
    • Thread