美文网首页
NSTimer 不同系统崩溃的问题

NSTimer 不同系统崩溃的问题

作者: 熊梓君 | 来源:发表于2017-07-25 21:24 被阅读120次

废话不多说,直接说问题, App 发布 TestFlight 之后,有些用户说打开 App 后就崩溃,我的个天直接吓傻,好吧,问题出来了就解决吧。

  • 问题
app due to uncaught exception 'NSInvalidArgumentException', 
reason: '+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]:
  • 解决
到这里崩溃了
[NSTimer scheduledTimerWithTimeInterval: 180.0f repeats: YES block:^(NSTimer * _Nonnull timer) {
// Block
}];
然后换成:
[NSTimer scheduledTimerWithTimeInterval: 180.0f
                                        target:self
                                selector: @selector(method)
                                      userInfo: nil
                                       repeats: YES];
即可。
原因当然是因为该方法支持的系统版本不对的原因。

相关文章

网友评论

      本文标题:NSTimer 不同系统崩溃的问题

      本文链接:https://www.haomeiwen.com/subject/zzugkxtx.html