Not sure the OP's question and/or the accepted answer here is still valid, at least not as of the results I'm seeing with iOS9/Xcode7.
Here's a (slightly cleaned up) version of the OP's code...
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool
{
NSString* __strong strongPtr = [[NSString alloc] initWithFormat:@"Life, Universe, Everything: %d", 42];
NSString* __weak weakPtr = strongPtr;
NSLog(strongPtr == weakPtr ? @"Same" : @"Different");
NSLog(@" StrongPtr: %@", strongPtr);
NSLog(@" weakPtr: %@", weakPtr);
NSLog(@"Changing strongPtr to something else...");
// After this is set, there is no strong reference to the created object
strongPtr = [[NSString alloc] initWithFormat:@"Drink: %@", @"Pan-galactic Gargle Blaster!"];
NSLog(strongPtr == weakPtr ? @"Same" : @"Different");
NSLog(@" StrongPtr: %@", strongPtr);
NSLog(@" weakPtr: %@", weakPtr);
}
return 0;
}
And here's the (truncated) output...
Same
StrongPtr: Life, Universe, Everything: 42
weakPtr: Life, Universe, Everything: 42
Changing strongPtr to something else...
Different
StrongPtr: Drink: Pan-galactic Gargle Blaster!
weakPtr: (null)
Program ended with exit code: 0
Here accessing the weak references in the conditionals (as per the accepted answer's explanation) doesn't keep an auto-released reference around as you can see by the (null) in the output.
...or did I accidentally change the OP's question to the point where I hid what he's seeing? Or perhaps it's because now ARC is on by default?