NSObject의 PerformectorOnMainThread : WithObject : WaituntIldone :
-
03-07-2019 - |
문제
제외되는 예외는 어떻게 발생합니다 myMethod:
NSObject를 통해 호출되는 경우 performSelectorOnMainThread:withObject:waitUntilDone:
?
특히 전화의 범위에서 잡을 수 있습니까? performSelectorOnMainThread
이와 같이...
@try {
[self performSelectorOnMainThread:@selector(myMethod) withObject:nil waitUntilDone:YES];
} @catch(NSException *e) {
//deal with exception raised in myMethod here??
}
Waituntildone이라면 이것의 의미론이 이상하다는 것을 알고 있습니다. NO
.
해결책
당신은 그렇게 잡을 수 없습니다. 코코아는 예외를 콘솔에 잡아서 기록 할 수 있지만, -성능이라는 스레드에서 다시 제출하지는 않습니다. 대신, 당신은 그들을 -mymethod : (또는 -mymethod라고 부르는 포장지 :) 다른 스레드가 읽을 수있는 곳에 보관하도록 할 수 있습니다.
제휴하지 않습니다 StackOverflow