*** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object
*** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object
- Subject: *** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object
- From: Daniel Child <email@hidden>
- Date: Tue, 19 Feb 2008 13:00:28 -0500
I have an NSMutableDictionary instance variable. When I try to set
its value using setObject: forKey I get this message:
*** -[NSCFDictionary setObject:forKey:]: mutating method sent to
immutable object
The value I'm sending is an NSString. I would have expected this to
occur if I tried setting an object for an NSDictionary.
Why would a mutable collection be considered immutable? Thanks!
@interface Step1WindowController : NSWindowController
{
IBOutlet NSButton *doneButton;
IBOutlet NSTextField *valueField;
NSString *value;
NSMutableDictionary *data;
}
.... (method declarations, including standard accessors)
- (id) init
{
data = [[NSMutableDictionary alloc] init];
return self = [super initWithWindowNibName: @"Step1Window"];
}
... ACCESSOR METHODS ...
... PROBLEM BELOW ...
- (IBAction) sendValueToMaster: (id) sender
{
NSString *theValue = [valueField stringValue];
if ([theValue isEqualTo: @""]) {
... << do an alert panel>> // which works
}
else {
[self setValue: theValue];
[[self data] setObject: [self value] forKey: @"step 1 value"]; //
**** ERROR OCCURS HERE
[[NSApp delegate] setData: data];
}
}
I have also tried
[data setObject: value forKey: @"step 1 value"];
[data setObject: [self value] forKey: @"step 1 value"]; etc.
to see if the accessors were influencing this. They don't. Same error...
_______________________________________________
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