ブロックコード内で例外をキャッチする適切な方法はありますか?
次のコードを取得しました。
void(^callback(int) = ^(int respond){
[self DoSomethingWithRespond:respond]; //this throws an exception
};
-(void)DoSomethingWithRespond:(int)respond{
if(respond == 400){
NSException *exception = [NSException
exceptionWithName:@"Failed"
reason:logMessage
userInfo:nil];
@throw exception
}
}
コールバック メソッドは別のスレッドから呼び出されます。応答が 400 に等しい場合、DoSomethingWithRespond
メソッドは例外をスローします。