NSException* ex = [[NSException alloc] initWithName:@"ExceptionName" // just for test reason:@"XXX" userInfo:nil]; // CustomNSException* ex = [[CustomNSException alloc] initWithName:@"CustomNSExceptionName" // just for test// reason:@"XXX"// userInfo:nil];// @try { bool error = YES; if (error) { @throw ex; } } // @catch ( CustomNSException *exception ) {// NSLog(@"CustomNSException.name = %@" , CustomNSException.name);// NSLog(@"CustomNSException.reason = %@" , CustomNSException.reason);// // // 彈出警告框,提示異常資訊// UIAlertView* alert = [[UIAlertView alloc] initWithTitle:CustomNSException.name// message:CustomNSException.reason// delegate:nil// cancelButtonTitle:nil// otherButtonTitles:nil];// // [alert show];// [alert release];// } @catch ( NSException *exception ) { NSLog(@"exception.name = %@" , exception.name); NSLog(@"exception.reason = %@" , exception.reason); } @finally { NSLog(@"@finally"); }