Try something like this:
NSString *myString; NSString* __weak myString1; @autoreleasepool{ myString= [NSString stringWithFormat:@"string1"]; myString1= myString; myString= nil; } NSLog(@"%@, %@",myString,myString1);
Explanation
You have probably noticed that there are many ways to select a line or an object in general:
1) [NSString stringWithFormat: ...] / [[NSString alloc] initWithFormat: ...];
2) [NSArray arrayWithArray: ...] / [[NSArray alloc] initWithArray: ...];
...
(Also for many other classes)
The first category of methods returns an object with automatic implementation. The second is not an auto-implemented object. Indeed, if in the above code you use alloc + initWithFormat: instead of stringWithFormat: you do not need an autostart pool to see that both objects are equal to zero.
source share