【发布时间】:2014-03-28 15:09:57
【问题描述】:
这是我的代码:
@interface YQViewController ()
@property (nonatomic, strong) UILabel *lb1;
@end
@implementation YQViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"title";
self.lb1 = [[UILabel alloc]init];
NSLog(@"retain count is %ld", CFGetRetainCount((__bridge CFTypeRef)self.lb1));
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
如您所见,我将+alloc 和-init 发送到self.lb1,我认为self.lb1 的保留计数应该等于1,但控制台输出为2。有人能告诉我原因吗。( ARC 启用、xcode 5、OSX 10.9.1、iOS 7 模拟器)。
【问题讨论】:
标签: ios automatic-ref-counting