[self performSelectorOnMainThread:@selector(customFoo:) withObject:obj waitUntilDone:YES];
和呼吁
[self customFoo:obj];
据我所知,如果第二个是在主线程调用,没有他们两个有什么区别...是对?
他们两人之间的基本区别是什么?
[self performSelectorOnMainThread:@selector(customFoo:) withObject:obj waitUntilDone:YES];
和呼吁
[self customFoo:obj];
据我所知,如果第二个是在主线程调用,没有他们两个有什么区别...是对?
他们两人之间的基本区别是什么?
运行时行为是相同的。但是编译代码时会有差异:如果定义了方法customFoo:
,则第二个代码只会编译。
performSelector:向接收方发送指定的消息并返回消息的结果。
PerformSelector用于调用方法,只要你想执行,这意味着你有选项来选择不同的选项来执行特定的任务(方法)示例...
– performSelector:withObject:afterDelay: // will execute method after specific delay..
– performSelector:withObject:afterDelay:inModes:
– performSelectorOnMainThread:withObject:waitUntilDone:
– performSelectorOnMainThread:withObject:waitUntilDone:modes:
– performSelector:onThread:withObject:waitUntilDone:
– performSelector:onThread:withObject:waitUntilDone:modes:
– performSelectorInBackground:withObject:
//在后台执行任务。所以,你ManinThread(应用程序)将不会停止responding..like多线程..
凡直接法([self customFoo:obj];
)将不会执行任务提供选择..
For more and detailed explanation visit this reference..
希望,这将有助于你...