• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scope of [NSMutableDictionary setObject:] in an array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Scope of [NSMutableDictionary setObject:] in an array
      • From: Ondra Cada <email@hidden>
    • Re: Scope of [NSMutableDictionary setObject:] in an array
      • From: Chris Giordano <email@hidden>
  • Prev by Date: An observation about executing AppleScripts from within Cocoa
  • Next by Date: Re: setFrameUsingName , setFrameAutosaveName
  • Previous by thread: An observation about executing AppleScripts from within Cocoa
  • Next by thread: Re: Scope of [NSMutableDictionary setObject:] in an array
  • Index(es):
    • Date
    • Thread