這裏是我的代碼:iOS的保留與ARC數使
@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模擬器)。
http://whentouseretaincount.com/ –