Re: NSDictionary mutability test
Re: NSDictionary mutability test
- Subject: Re: NSDictionary mutability test
- From: Charles Steinman <email@hidden>
- Date: Mon, 8 Dec 2008 09:29:16 -0800 (PST)
----- Original Message ----
> From: "email@hidden" <email@hidden>
> To: email@hidden
> Sent: Monday, December 8, 2008 9:15:45 AM
> Subject: NSDictionary mutability test
>
> There are a number of posts detailing with the ethics of the issue of
> determining an object's mutability.
> eg: http://www.cocoabuilder.com/archive/message/cocoa/2004/7/7/111173
> Does anyone have a current informed pragmatic opinion on how to deal with the
> following example?
>
> I am not trying to determine program flow by determining mutability, merely
> trying to limit the number of self inflicted injuries.
> The following never seems to assert, regardless of whether dict is mutable or
> not.
>
> NSAssert([dict isKindOfClass:[NSMutableDictionary class]], @"dict is not
> mutable");
This is explained in the thread you referenced. All NSDictionary objects are instances of NSCFDictionary. Thus the only way to check if they are mutable through public API is to try mutating them and see if Cocoa throws a hissy fit.
Cheers,
Chuck
_______________________________________________
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