Re: MutableDictionary setValue:forKeyPath - strange behavior
Re: MutableDictionary setValue:forKeyPath - strange behavior
- Subject: Re: MutableDictionary setValue:forKeyPath - strange behavior
- From: Jason Foreman <email@hidden>
- Date: Sun, 20 Sep 2009 14:11:14 -0500
On Sep 20, 2009, at 1:54 PM, Steve Cronin wrote:
Kyle;
Thanks for such a speedy response. (and on a Sunday afternoon too!)
That code is a fairly complex set of interlocking methods.
Why would the construction of this NSMutableDictionary have anything
to do with this error?
Because the error quite clearly indicates you're trying to mutate an
immutable object, so myBaseSettings seems to be not an
NSMutableDictionary like you believe it to be, but just an NSDictionary.
I believe the reason using a multipart keypath works is that it
conceptually ends up doing something like this:
[myBaseSettings setValue:@"whatever" forKeyPath:@"foo.bar"] =>
id tmp = [myBaseSettings valueForKey:@"foo"];
[tmp setValue:@"whatever" forKey:@"bar"];
You aren't mutating myBaseSettings in this case, but mutating whatever
is stored in "foo" in myBaseSettings. Whatever *that* is is likely a
mutable object, but your myBaseSettings is not.
So somewhere in your "complex set of interlocking methods" it seems
you're ending up with an immutable myBaseSettings instead of a mutable
one.
Jason
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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