The following code is not doing what I expect.
We have a strong string and a weak string. My understanding of ARC is that when there are no references to a weak variable it will be deallocated, however, the last line the weak string still has a value.
// Make a strong and weak variable
__strong NSString *strongString = @"Moo";
__weak NSString *weakString = nil;
weakString = strongString;
NSLog(@"weak: `%@` \t strong: `%@`", weakString, strongString);
// As expected this prints,
// weak: `Moo` strong: `Moo`
// Now set the weak reference to nil
weakString = nil;
NSLog(@"weak: `%@` \t strong: `%@`", weakString, strongString);
// As expected this prints,
// weak: `(null)` strong: `Moo`
// Now reset the weak variable and set the strong variable to nil
weakString = strongString;
strongString = nil;
NSLog(@"weak: `%@` \t strong: `%@`", weakString, strongString);
// Unexpectedly this prints,
// weak: `Moo` strong: `(null)`
// I was expecting to see weak: `(null)` strong: `(null)`
Unless I have misunderstood, it looks like the weak variable has become strong.