Tuesday, September 04, 2012

iOS Objective-C performSelector static method


It's tested OK to use the following static method calls.
Tested on Xcode Version 4.4.1 (4F1003), Apple LLVM Compiler 4.0
    [[StaticMethodClass classperformSelectorInBackground:@selector(runInThreadMethod)withObject:nil];
    [StaticMethodClass performSelectorInBackground:@selector(runInThreadMethod)withObject:nil];
    [StaticMethodClass performSelectorOnMainThread:@selector(runInThreadMethod)withObject:nil waitUntilDone:NO];
    [StaticMethodClass performSelector:@selector(runInThreadMethod) withObject:nil];
Although, there is no auto-code-completion, but it runs fine.
But when use "target", it's NOT ok to use the Class itself, should use "[StaticMethodClass class]" as the target. like.
 [NSTimer scheduledTimerWithTimeInterval:1.0 target:[StaticMethodClass classselector:@selector(runInThreadMethod) userInfo:nil repeats:NO];

No comments:

Post a Comment