示例
#import <Foundation/Foundation.h>
#import "Fraction.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
//主动抛出异常
//@throw [NSException exceptionWithName:@"context show" reason:@"crush's reason" userInfo:nil];
Fraction *f = [[Fraction alloc] init];
@try {
[f noSuchMethod];
}
@catch (NSException *exception) {
NSLog(@"Caught %@%@", [exception name], [exception reason]);
}
@finally {
NSLog(@"finally...");
}
NSLog(@"Execution continues!");
}
return 0;
}