Re: Determining whether a dictionary is mutable or not
Re: Determining whether a dictionary is mutable or not
- Subject: Re: Determining whether a dictionary is mutable or not
- From: Ken Ferry <email@hidden>
- Date: Fri, 14 Jan 2011 22:36:54 -0800
I'm not sure this has been made clear: It is intentional that it is
difficult to determine whether a dictionary is mutable.
That's because you shouldn't do it. Whether a dictionary is mutable
_to_you_ is a matter of what's in the header for the method you obtained it
from.
Suppose that some object keeps a mutable array as its internal state. It
also has an accessor that lets you look at the array as an immutable array.
If you introspect it and realize its mutable, is it safe to mutate? No!
It's part of the object's internal state, you cannot just mess with it.
It is unsafe in general to introspect mutability.
-Ken
Cocoa Frameworks
On Fri, Jan 14, 2011 at 3:01 PM, Tito Ciuro <email@hidden> wrote:
> Thanks a lot everyone for the great feedback. I really appreciate it! :-)
>
> Cheers,
>
> -- Tito
>
> On Jan 14, 2011, at 6:39 PM, Corbin Dunn wrote:
>
> >
> > On Jan 14, 2011, at 4:44 AM, 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.
> >
> > I think you should work backwards on this one...break on NSLog and go
> from there....
> >
> > Something's mutating an dictionary that shouldn't be mutated.
> >
> > corbin
> >
> >
>
> _______________________________________________
>
> 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
>
_______________________________________________
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