在開發(fā)APP時,我們通常都會需要捕獲異常稚失,防止應用程序突然的崩潰,添加異常處理
@try {
// 可能會出現(xiàn)崩潰的代碼
// meg = [MemberMeg parseFromData:data];
} @catch (NSException *exception) {
// 捕獲到的異常exception
NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
dispatch_async(dispatch_get_main_queue(), ^{
DXAlertView *alert = [[DXAlertView alloc]initWithTitle:@"提示" contentText:[NSString stringWithFormat:@"未知錯誤栋艳,稍后再試"] leftButtonTitle:nil rightButtonTitle:@"確定"];
[alert show];
});
} @finally {
// 結果處理
}