代码:
- (void)viewDidLoad{
[super viewDidLoad];
NSString* string = @"aSrting";
self.weakString = string;
NSLog(@"string: %@,%p",string,string);
NSLog(@"weakString: %@,%p",self.weakString,self.weakString);}
-(void)viewWillAppear:(BOOL)animated{
NSLog(@"weakString: %@,%p",self.weakString,self.weakString);}
- (void)viewDidAppear:(BOOL)animated{
NSLog(@"weakString: %@,%p",self.weakString,self.weakString);}
结果:
2015-11-08 18:17:06.022 HZStrongWeakTest[4514:370204] string: aSrting,0x101b33088
2015-11-08 18:17:06.023 HZStrongWeakTest[4514:370204] weakString: aSrting,0x101b33088
2015-11-08 18:17:06.023 HZStrongWeakTest[4514:370204] weakString: aSrting,0x101b33088
2015-11-08 18:17:06.026 HZStrongWeakTest[4514:370204] weakString: aSrting,0x101b33088
问:'aString'不是发布。 'weakString'不是持有对象。 它是如何工作的?