Scope of [NSMutableDictionary setObject:] in an array
Scope of [NSMutableDictionary setObject:] in an array
- Subject: Scope of [NSMutableDictionary setObject:] in an array
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 13 Sep 2002 18:51:58 +0100
Could someone explain to me why it is that, whereas the following code
works just fine...
- (IBAction)saveProject:(id)sender
{
NSMutableDictionary *values = [NSMutableDictionary dictionary];
NSString *listString = [NSString stringWithString:[textView1
string]];
NSString *partsListString = [NSString stringWithString:[textView2
string]];
[values setObject:[textField stringValue] forKey:@"Group"];
[values setObject:listString forKey:@"Files List"];
[values setObject:partsListString forKey:@"Parts List"];
[projects replaceObjectAtIndex:projectCounter withObject:values];
[prefs setObject:projects forKey:@"Projects"];
}
...the following version results in the current values of the text view
strings replacing ALL the @"Files List" and @"Parts List" values in ALL
the dictionaries in "projects"?
- (IBAction)saveProject:(id)sender
{
NSMutableDictionary *values = [NSMutableDictionary dictionary];
[values setObject:[groupField stringValue] forKey:@"Group"];
[values setObject:[textView1 string] forKey:@"Files List"];
[values setObject:[textView2 string] forKey:@"Parts List"];
[projects replaceObjectAtIndex:projectCounter withObject:values];
[prefs setObject:projects forKey:@"Projects"];
}
-Jeremy
========================================
email@hidden // email@hidden
The Alchemy Pages:
- fractious fiction at
http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.