美文网首页
NSTimer的坑

NSTimer的坑

作者: yehkong | 来源:发表于2017-06-03 17:10 被阅读0次

    这有三个API都是新增的,标识有API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0))。

    • .+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer *timer))block;

    • . + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer *timer))block;

    • .- (instancetype)initWithFireDate:(NSDate *)date interval:(NSTimeInterval)interval repeats:(BOOL)repeats block:(void (^)(NSTimer *timer))block;

    特别是前两个,跟以下api一时手快容易混淆,容易让使用低于10.0系统的用户直接闪退,报错unrecognized selector;

    • .+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti invocation:(NSInvocation *)invocation repeats:(BOOL)yesOrNo;

    • .+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti invocation:(NSInvocation *)invocation repeats:(BOOL)yesOrNo;

    • .+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(nullable id)userInfo repeats:(BOOL)yesOrNo;

    • .+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(nullable id)userInfo repeats:(BOOL)yesOrNo;

    相关文章

      网友评论

          本文标题:NSTimer的坑

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