If a method defines a return, but trycatch works and catch a exception, I thought the method will return a nil, but actually it returns the caller. I am curious about what happened indeed in this operation. Here is the code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *string = [self testMethod];
NSLog(@"%@",string);
return YES;
}
- (NSString *)testMethod {
@try {
@throw [NSException exceptionWithName:@"test exception" reason:@"test" userInfo:nil];
return @"normal return";
} @catch (NSException *exception) {
} @finally {
}
}
In this situation, I debug the code and found the string is APPDelegate instance.