问题
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