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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to