3
默認情況下,通過方法alloc
或copy
返回的對象的retain count
等於1,因此您必須自行釋放它。NSTimer內存管理問題
但通過的NSTimer示例代碼
// in one method start the timer (which myTimer is an Class Instance) myTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(method:) userInfo:nil repeats:YES]; // in another method [myTimer invalidate]; myTimer = nil;
我的問題是,爲什麼[的NSTimer血清膽鹼酯酶**]返回一個對象,你不必挽留,但你可以在任何地方訪問它。你不需要釋放它,只需要調用invalidate
就可以了。