I have 2 properties that are weak, declared as follows :
@property (nonatomic, weak) NSString *weakProperty;
@property (nonatomic, weak) NSMutableString *weakMutableProperty;
- (void)testNonMutable
{
NSString *name = @"ABC";
self.weakProperty = name;
name = nil;
NSLog(@"Printing weak property %@",self.weakProperty);
}
- (void)testMutable
{
NSMutableString *name = [NSMutableString stringWithString:@"ABC"];
self.weakMutableProperty = name;
name = nil;
NSLog(@"Mutable : Printing weak property %@",self.weakMutableProperty);
}
I was expecting the NSLog statement to print nil , but it prints ABC in the first method. However it does in the second method. Can someone please help me ?