Re: [NSMutableArray array]
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