微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NSTimer崩溃

如何解决NSTimer崩溃

感谢您的帮助。试用基本的progressIndicator动画。这崩溃了,并指出:“ TO8 Generator经过优化编译-步进的行为可能很奇怪;变量可能不可用。” TO8 Generator显然是应用程序。

消息:“选择器'scheduledTimerWithTimeInterval:selector:userInfo:repeats:'的未知类方法

有见识吗?再次谢谢你。

NSTimer *timer;
int count;  

if(!timer)
{
    timer = [NSTimer scheduledTimerWithTimeInterval:0.01
                                             target:self
                                           selector:@selector(checkThem:)
                                           userInfo:nil
                                            repeats:YES];
    [progressBar startAnimation: self];
}

-(void)checkThem:(NSTimer *)aTimer
{
    count++;
    if(count > 100)
    {
        count = 0;
        [timer invalidate];
    
        timer = NULL;
        [progressBar setDoubleValue:0.0];
        [progressBar stopAnimation: self];
    }
    else
    {
        [progressBar setDoubleValue:(100.0 * count) / 100];
    }
}

解决方法

Andy的评论提示我检查我的Scheme配置。启用了“ DeBug可执行文件”。因此,该函数在编译后将无法使用。然后,我禁用了该选项。这样做之后一切都很好。对不起,麻烦了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。