下面的这些函数是定义在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");
}
本文探讨了Objective-C与Swift两种编程语言在iOS开发领域的应用与区别,包括其优势、使用场景及迁移策略。
107

被折叠的 条评论
为什么被折叠?



