On 14-Jan-2011, at 8:44 PM, Tito Ciuro wrote:
> Hi Pablo,
>
> On Jan 14, 2011, at 1:35 PM, Pablo Pons Bordes wrote:
>
>> Hello,
>>
>> To determine if a dictionary is mutable or Inmutable you just need to use
>> the isKindOfClass method, instead of use respondsToSelector.
>>
>> I did a test to reproduce your problem and couldn't reproduce your problem,
>> so my conclusion is that actually you are receiving a mutable Dictionary
>> when you think is unMutable
>
> Hm. No, I'm not getting a mutable dictionary because I'm seeing a log message
> complaining that I'm trying to call setObject:forKey: on an immutable object.
>
> Thanks!
>
> -- Tito
Again let me say that if the signature to your method is
-(void)doSomethingWithADictionary:(NSDictionary*)dictionary;
you shouldn't be trying to figure out whether that dictionary is mutable and
mutate it. Any caller has at least a reasonable expectation (if not an absolute
right) to assume that the method is expecting something it cannot mutate and
will not try mutating it. If you wish to mutate that argument, you must make a
mutable copy of it and leave the thing the caller sent you intact.
If you want it to be otherwise make the signature
-(void)doSomethingWithADictionaryICanReallyMessUpForYou:(NSMutableDictionary*)dictionary
and make all the callers send mutable objects they know they don't need later
and which they are forewarned you may be messing about with.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]