Method calling via performSelectorOnMainThread Vs Normal method calling

こ雲淡風輕ζ 提交于 2020-02-24 07:44:36

问题


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

For Exa.

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

NOW Call this method using these two senario:

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

or

[self sampleCALL];

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


回答1:


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];];

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



来源:https://stackoverflow.com/questions/10684488/method-calling-via-performselectoronmainthread-vs-normal-method-calling

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!