Re: immutable collection given to mutating function error
Re: immutable collection given to mutating function error
- Subject: Re: immutable collection given to mutating function error
- From: Ken Thomases <email@hidden>
- Date: Sun, 22 Feb 2009 12:40:07 -0600
On Feb 22, 2009, at 11:17 AM, Michael Domino wrote:
I have a situation where I'm writing a preferences file and I have a
major section and one or more minor sections, like this:
Settings
Logging
Initialization
Everything actually works fine, except that I get this error when
writing a minor section:
2009-02-22 10:10:56.466 Identity Finder[40754:813]
CFDictionarySetValue(): immutable collection 0x11ad8f0 given to
mutating function
[...]
The question is: does CFDictionaryGetValueIfPresent always return an
immutable object
No. It returns the value that's in the dictionary.
and is there another api call that will return a mutable dictionary?
Am I doing this the wrong way?
The problem isn't in how you're getting stuff out of your dictionary,
it's how the dictionary is created and filled. I suspect you're using
the CFPropertyList or CFPreferences APIs, which by default give you
immutable object graphs.
By the way, none of this is Cocoa-specific. Perhaps Cocoa-Dev isn't
the best list for this.
Regards,
Ken
_______________________________________________
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