3

performSelectorOnMainThreadperformSelectorを使用せずに同じメソッドを使用して呼び出した場合の違いを教えてください。

エクサ用。

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

次の 2 つのシナリオを使用して、このメソッドを呼び出します。

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

また

[self sampleCALL];

これら2つのメソッドはどのように実行されていますか? この概念を適切に見つけるのを手伝ってください。

4

1 に答える 1

2

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.

于 2012-05-21T11:43:03.473 に答える