通过performSelectorOnMainThread调用方法调用普通方法 [英] Method calling via performSelectorOnMainThread Vs Normal method calling

查看:137
本文介绍了通过performSelectorOnMainThread调用方法调用普通方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 performSelectorOnMainThread 调用方法并且在没有performSelector的情况下调用相同的方法时,任何人都可以告诉我有什么不同。

can any one tell me what is different when I call method using performSelectorOnMainThread and calling same method without performSelector.

Exa。

-(void)sampleCALL{
     ..........
}

现在使用这两个参数调用此方法:

NOW Call this method using these two senario:

[[self performSelectorOnMainThread:@selector(sampleCALL) withObject:nil waitUntilDone:NO];];

[self sampleCALL];

如何执行这两种方法?
请帮我正确找到这个概念。

How these two method are getting executed? Please help me to find this concept properly.

推荐答案

第一个案例 [self sampleCALL]; 您的方法将在当前控制的线程中调用。它将保持所有堆栈操作,它为从另一个方法调用方法做了什么。

in firs one case [self sampleCALL]; your method will be called in the thread where control was at current time. it will maintain all the stack manipulation what it does for method calling from another method.

while

[[self performSelectorOnMainThread:@selector(sampleCALL) withObject:nil waitUntilDone:NO];];

调用主线程中的方法,无论控件当前线程是什么。所有UI操作始终在主线程中执行。

calls the method in main thread whatever the controls current thread is. All UI actions are performed in main thread always.

这篇关于通过performSelectorOnMainThread调用方法调用普通方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆