My project use ARC. I tested with the code below:
NSString __weak *string; @autoreleasepool { string = [NSString stringWithString:@"AAA"]; } NSLog(@"string: %@", string);
I think it output as:
string: (null)
but it actually output:
string: AAA
I don't understand it. What is the effect of __weak?
EDIT:
And this code below:
NSString __weak *string; NSString __strong *str; @autoreleasepool { str = [NSString stringWithFormat:@"%@", @"AAA" ]; string = str; } NSLog(@"string: %@", string);
It also output as:
string: AAA