美文网首页
NSTimer 调用类方法(静态方法)

NSTimer 调用类方法(静态方法)

作者: 乐视薯片 | 来源:发表于2016-12-01 17:12 被阅读59次

有人问NSTimer 怎么调用类方法,自己想想还不知道怎么办,平时传的都是些对象方法啊,类方法怎么传啊,原来so easy:

_timer= [NSTimer scheduledTimerWithTimeInterval:1.0f target: self selector:@selector(updateTimer) userInfo:nil repeats:NO];

这样,updateTimer 是一个对象方法,如果想调用类方法,即静态方法,只需把target参数改成:[ClassName class]即可,在此记录一下吧。

相关文章

网友评论

      本文标题:NSTimer 调用类方法(静态方法)

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