NSTimer中调用静态方法

Usually we schedule NSTimer like:


    [NSTimer scheduledTimerWithTimeInterval:2.0
             target:instance
             selector:@selector(targetMethod)
             userInfo:nil
             repeats:YES];

targetMethod is an instance method of the instance.

What if we want to schedule to run a static method (or class method) of a class?
Just replace the "instance" with "[ClassA class]".


    [NSTimer scheduledTimerWithTimeInterval:2.0
             target:[ClassA class]
             selector:@selector(staticMethod)
             userInfo:nil
             repeats: YES];

"staticMethod" is a static method of ClassA.

"[ClassA class]" is the target object.


http://situee.blogspot.hk/2012/09/ios-objective-c-schedule-nstimer-with.html

你可能感兴趣的:(NSTimer中调用静态方法)