Re: Scope of [NSMutableDictionary setObject:] in an array
Re: Scope of [NSMutableDictionary setObject:] in an array
- Subject: Re: Scope of [NSMutableDictionary setObject:] in an array
- From: Ondra Cada <email@hidden>
- Date: Fri, 13 Sep 2002 21:46:39 +0200
On Friday, September 13, 2002, at 07:51 , Jeremy Dronfield wrote:
Could someone explain to me why it is that, whereas the following code
works just fine...
...
NSString *listString = [NSString stringWithString:[textView1 string]]
;
...
[values setObject:listString forKey:@"Files List"];
...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"?
...
[values setObject:[textView1 string] forKey:@"Files List"];
You posted your own answer: since a text view contains a mutable string,
whenever you place it (as in the latter case), its *current* contents will
be always shown. If you store a copy (as in the former case), the copy of
course won't change.
That dictionary retains (and not copies) its values is, I believe,
documented. That [textview string] does not return a snapshot but the live
internal mutable string is not (at least so far as I recall), but your
code proves it ;)
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.