ok, it was suggested to me that i shouldn't use copies of strings as i
do here
[informationCenter sendCommand: [NSMutableString stringWithString:
theString]];
[lastCommand setString: [NSString stringWithString: theString]];
[myCommandArray1 addObject: [NSString stringWithString: theString]];
according to my experience and testing, i've found out something
dangerous about doing it your way. here's an example:
[theString setString: @[EMAIL PROTECTED]
"one"];
[informationCenter sendCommand: theString];
[lastCommand setString: theString];
[myCommandArray1 addObject: theString];
[theString setString: @[EMAIL PROTECTED]
"two"];
you would assume that "one" would be sent to the informationCenter,
stored in lastCommand, and appended to myCommandArray1 and you would be
correct however, when you set theString to "two" all the others will
change as well (unless sendCommand already sent the command in which
case IT won't be changed). at the end of the process, you'd expect
"one" to be the last item in myCommandArray1 and you'd be wrong.
now here's the question, how would you geniuses out there write what i
wrote in a SAFE way (a way in which will not be changed in the manner i
mentioned) and still not require the copying using stringWithString?


|