MutableDictionary setValue:forKeyPath - strange behavior
MutableDictionary setValue:forKeyPath - strange behavior
- Subject: MutableDictionary setValue:forKeyPath - strange behavior
- From: Steve Cronin <email@hidden>
- Date: Sun, 20 Sep 2009 13:35:57 -0500
Folks;
I have recently converted to XC & IB 3.2
I've updated my project to be a 3.2 project using a baseSDK of 10.6
with deployment target of 10.4
I've run the static analyzer and have no analyzer issues as well as no
compiler nor IB warnings
I'm feeling good about this but now code that worked under Leopard is
no longer working.
I have an instance variable which is an NSMutableDictionary *
myBaseSettings
I run a method which steps thru the keys in a local NSDictionary
(sessionSettings) to possibly set some values into myBaseSettings
NSDictionary * sessionSettings = ...;
NSArray *values, *keys = [sessionSettings allKeys];
int dictCount = [keys count];
if (dictCount>0) {
values = [sessionSettings allValues];
NSString *thisKey, *thisValue;
for (i=0 ; i<dictCount; i++) {
thisKey = [keys objectAtIndex:i];
thisValue = [values objectAtIndex:i];
if ([thisKey isEqualToString:interestingKey1]) {
//NOTE: ALL of these cause the same exception
[myBaseSettings setValue:thisValue forKeyPath:thisKey];
[myBaseSettings setValue:thisValue forKey:thisKey];
[myBaseSettings setObject:thisValue forKey:thisKey];
} else if ([thisKey isEqualToString:interestingKey2]) {
...
} else {
[myBaseSettings setValue:thisValue forKeyPath:thisKey];
}
}
}
(NOTE: I use setValue:forKePath because the sessionSetting keys can be
dictionaries)
I get an exceptions thrown whenever thisKey is a normal 'key' (ie
"workPhone") but NOT when thisKey is a 'keyPath' (ie.
"nameDict.firstName")
'*** -[NSCFDictionary setObject:forKey:]: mutating method sent to
immutable object'
The key and value are both valid strings (verified using 'po' gdb)
It seems like somehow the instance variable is not being treated as an
NSMutableDictionary but why?
Thanks for any thoughts on this - I'm baffled!
Steve
_______________________________________________
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