NSTimer深入研究

NSTimer深入研究

在使用NSTimer的时候老是出现崩溃的情况,感觉有很多地方都是使用不当的地方,所以深入研究一下。

1.什么时候该[retry_connect_timer invalidate];
苹果官方文档里面的原话if you create a repeating timer, you must invalidate it when you want it to stop firing.
不是什么时候都能用invalidate,只有当你创建了一个repeating timer的时候,你才能调用那个方法

2.那么如何关闭no repeating timer?
a.
              retry_connect_timer = [NSTimer  scheduledTimerWithTimeInterval:retryIntrval target:self selector:@selector(connect_camera) userInfo:nil repeats:NO];

b.
-(void)connect_camera
{
    retry_connect_timer = nil;

}

c.
其他函数
        if (retry_connect_timer) {
            
            [retry_connect_timer invalidate];
            retry_connect_timer = nil;
        }


“双语播放器”已在app store上架,欢迎大家前去下载(主要用于看电影,学英语,程序员一定要学好英语!)

这里是链接:

https://itunes.apple.com/cn/app/shuang-yu-bo-fang-qi-kan-dian/id950279764?mt=8


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值