文章标题
2016-07-30 16:57
232 查看
NSTime 写在-(void)dealloc不被释放
-(void)createTime { self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(onTimerCount) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; } -(void)dealloc { if (self.timer) { [self.timer invalidate]; self.timer = nil; } }
直接按照上面方式释放是无效的
可以在\
-(void)viewWillDisappear:(BOOL)animated里面释放
方式二:
可以参考http://www.cocoachina.com/ios/20150710/12444.html