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.
No comments:
Post a Comment