There is no problem with this as they are string literals. You have two different addresses for str and strTest. They simply go to the same object, which is a string literal. You have NOT created two separate instances of them.
Try
str = [NSString stringWithFormat:"%@", @"2"]; strTest = [NSSTring stringWithString:str];
or so. However, if you are still doing
NSArray *arr = [NSArray arrayWithObjects:@"1", str, @"3", @"4", @"5", @"6", nil];
and then
NSLog(@"object %x", [arr objectAtIndex:1]);
you will see that the object with index 1 in arr and the object str refers to are the same way because they are there and they must be the same.
source share