您的位置:首页 > 其它

文章标题

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: