ios arc __strong与__weak的一个小实例

今天测试了ios arc __strong与__weak的一个小实例,发现输出结果让人深思

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    strongStr = @"string";

    weakStr = strongStr;

    strongStr = nil;

    NSLog(@"strongStr:%@",strongStr);

    NSLog(@"weakStr:%@",weakStr);

}

输出结果

2012-10-29 11:32:31.713 testDemoButtonColor[2377:f803] strongStr:(null)

2012-10-29 11:32:31.717 testDemoButtonColor[2377:f803] weakStr:string

 

 

原文地址:https://www.cnblogs.com/hopeanCom/p/2744464.html