Hi all,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
I declare these pointers:
CFMutableDictionaryRef prefMajorSectionCFMutableDictionaryRef = 0;
CFMutableDictionaryRef prefMinorSectionCFMutableDictionaryRef = 0;
Then I obtain their values like this (this is just for a minor section):
const void* pVoid = 0;
Boolean present =
CFDictionaryGetValueIfPresent(prefMajorSectionCFMutableDictionaryRef,
minorSectionKeyCFStringRef, &pVoid);
if(!present) {
prefMinorSectionCFMutableDictionaryRef =
CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
} else {
prefMinorSectionCFMutableDictionaryRef =
static_cast<CFMutableDictionaryRef>(const_cast<void*>(pVoid));
}
If the section is not there and I create a new mutable CFDictionary,
there is no error. If the section is there, I get the error.
The question is: does CFDictionaryGetValueIfPresent always return an immutable object and is there another api call that will return a mutable dictionary? Am I doing this the wrong way?
Thanks for your advice. Michael Domino [email protected]
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]
