Re: RS: NSObject members class and isMemberOfClass
Re: RS: NSObject members class and isMemberOfClass
- Subject: Re: RS: NSObject members class and isMemberOfClass
- From: "Finlay Dobbie" <email@hidden>
- Date: Fri, 7 Sep 2007 14:15:42 +0100
On 07/09/2007, Mike Abdullah <email@hidden> wrote:
> OK, well as it says in the docs, NSArray and NSMutableArray are
> actually what is known as a class cluster. They are privately
> subclassed by Cocoa in various ways. e.g. NSCFArray.
>
> However, this shouldn't matter to you, it is an implementation
> detail. So the question that really matters is why you seem to need
> to know this? If you ask Cocoa to create a mutable array, it will,
> and you don't need to know or care about the actual class.
Well, it is slightly semantically broken - you ask for an NSArray and
you get an immutable instance of something which claims to be a
subclass of NSMutableArray back.
There isn't any supported way of determining if an array is mutable or
not. You probably could do it using undocumented private
CoreFoundation functions, but you shouldn't really need to. If you
have an array and you need to modify it, and you're not sure if it's
mutable or not, make a mutable copy. You might want to do this anyway,
since the person that handed you the array might not want it to be
modified underneath them. Or if they do, say that you require a
mutable array, and assume that it will be mutable.
-- Finlay
_______________________________________________
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