我有以下ARC啓用的碼理解弱引用
@property (nonatomic, weak) NSArray *a;
- (void)viewDidLoad
{
[super viewDidLoad];
self.a = @[@1, @2];
NSLog(@"ab is %@", self.a); //prints details of array
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
for (id element in self.a) { //empty here
NSLog(@"blah");
}
// Dispose of any resources that can be recreated.
}
這只是我曾經的self.a
的地方。這是我寫的一個測試程序,用於調試我的一個問題。
當我模擬內存警告self.a
消失?爲什麼?
只是出於教養的考慮:保留計數已被棄用,引用計數就是您所指的。如在,自動**引用計數**。 – CodaFi 2013-03-28 07:06:21