You must use copy if you want to guarantee the state of the object.
NSMutableString *mutString = [NSMutableString stringWithString:@"ABC"]; NSString *b = [mutString retain]; [mutString appendString:@"Test"];
At this point, b was just messed up by the third line there.
NSMutableString *mutString = [NSMutableString stringWithString:@"ABC"]; NSString *b = [mutString copy]; [mutString appendString:@"Test"];
In this case, b is the original string and is not modified by the third string.
This applies to all mutable types.
Joshua weinberg
source share