NSTimer 在共享类中因 EXC_BAD_ACCESS 崩溃
我有一个在共享类中运行的 NSTimer。 + (GlobalClass *)sharedInstance;
基本上它运行一次,第二次运行时,它就杀死了整个应用程序。
这就是我正在做的 NSTimer
myTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(moveMe)
userInfo:nil
repeats:YES];
方法 moveMe
目前只是一个空方法。所以它不应该是 moveMe
中发生的事情。
有人经历过这个吗?
I have an NSTimer
running in a shared class. + (GlobalClass *)sharedInstance;
Basically it runs once, and the second time it runs, it just killed the whole app.
This is how I'm doing the NSTimer
myTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(moveMe)
userInfo:nil
repeats:YES];
method moveMe
is just an empty method for now. So it shouldn't be something that's happening within moveMe
.
Has anyone experienced this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的选择器名称中似乎缺少冒号。
NSTimer
的选择器采用NSTimer
作为参数。创建计时器的代码应如下所示:注意
moveMe
后面的冒号。然后你的方法应该看起来像这样:It looks like you're missing the colon in your selector name. The selector for
NSTimer
takes anNSTimer
as an argument. Your code that creates the timer should look like this:Note the colon after
moveMe
. Your method should then look something like this: