search

Home  >  Q&A  >  body text

ios - NSTimer scheduledTimerWithTimeInterval返回(null)


如图,为什么获取到的timer居然是null,导致之后没法进行暂停等操作了。谢谢!

PHPzPHPz2890 days ago1042

reply all(3)I'll reply

  • 阿神

    阿神2017-04-17 13:08:17

    Later, I researched it clearly, and it was actually just the reason for the xcode display. You can already see by expanding (null) that _timer is already an object of NSCFTimer. (null) and nil here are completely different things.

    reply
    0
  • 阿神

    阿神2017-04-17 13:08:17

    [_timer invalidate];
    _timer = nil;
    

    Note that you have cleared _timer

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:08:17

    Generally speaking, for the selector parameter, the method passed in should take an NSTimer type parameter, that is, the subject's animateOneFrame method should take this parameter, so the passed in should be @selector(animateOneFrame:).

    reply
    0
  • Cancelreply