Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 以下两个方法调用之间的差异_Iphone_Objective C_Selector - Fatal编程技术网

Iphone 以下两个方法调用之间的差异

Iphone 以下两个方法调用之间的差异,iphone,objective-c,selector,Iphone,Objective C,Selector,及 正如我所知,如果在主线程上调用第二个线程,它们之间没有任何区别。。。是这样吗 它们之间的基本区别是什么?运行时行为是相同的。但是在编译代码时有一个区别:只有定义了方法customFoo:时,第二个才会编译。性能选择器:将指定的消息发送给接收方并返回消息的结果 PerformSelector用于根据需要调用方法,这意味着您可以选择不同的选项来执行特定的任务(方法)示例 [self customFoo:obj]; –performSelectorInBackground:withObject:

正如我所知,如果在主线程上调用第二个线程,它们之间没有任何区别。。。是这样吗


它们之间的基本区别是什么?

运行时行为是相同的。但是在编译代码时有一个区别:只有定义了方法
customFoo:
时,第二个才会编译。

性能选择器:将指定的消息发送给接收方并返回消息的结果

PerformSelector用于根据需要调用方法,这意味着您可以选择不同的选项来执行特定的任务(方法)示例

[self customFoo:obj];
–performSelectorInBackground:withObject:
//在后台执行任务。因此,ManinThread(应用程序)不会停止响应..就像多线程

其中,直接方法(
[self-customFoo:obj];
)不会为执行任务提供选择

希望,这将帮助你

[self customFoo:obj];
– 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: