• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MutableDictionary setValue:forKeyPath - strange behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >MutableDictionary setValue:forKeyPath - strange behavior (From: Steve Cronin <email@hidden>)
 >Re: MutableDictionary setValue:forKeyPath - strange behavior (From: Kyle Sluder <email@hidden>)
 >Re: MutableDictionary setValue:forKeyPath - strange behavior (From: Steve Cronin <email@hidden>)

  • Prev by Date: Re: MutableDictionary setValue:forKeyPath - strange behavior
  • Next by Date: Re: favicon of address
  • Previous by thread: Re: MutableDictionary setValue:forKeyPath - strange behavior
  • Next by thread: Re: MutableDictionary setValue:forKeyPath - strange behavior
  • Index(es):
    • Date
    • Thread