下面的这些函数是定义在NSObject中的,关于它们的具体含义,你可以在官方文档中找,或者google之,这里就不啰嗦了。
Sending Messages
– performSelector:withObject:afterDelay:
– performSelector:withObject:afterDelay:inModes:
– performSelectorOnMainThread:withObject:waitUntilDone:
– performSelectorOnMainThread:withObject:waitUntilDone:modes:
– performSelector:onThread:withObject:waitUntilDone:
– performSelector:onThread:withObject:waitUntilDone:modes:
– performSelectorInBackground:withObject:
+ cancelPreviousPerformRequestsWithTarget:
+ cancelPreviousPerformRequestsWithTarget:selector:object:
下面给出一个例子:
- (IBAction)Start:(id)sender {
[self performSelector:@selector(doSomething:)];
//[self doSomething:nil];
//[self per
[self performSelectorInBackground:@selector(doSomething:) withObject:nil];
}
-(void)doSomething:(id)inputData
{
if([NSThread isMainThread])
{
NSLog(@"in main thread");
}
else {
NSLog(@"not in main thread");
}
NSLog(@"kkkkk");
}