brintos

brintos / llvm-project-archived public Read only

0
0
Text · 778 B · a184718 Raw
48 lines · plain
1#import <Foundation/Foundation.h>2 3@interface MyClass : NSObject4{5}6- (int) callMeIThrow;7- (int) iCatchMyself;8@end9 10@implementation MyClass11- (int) callMeIThrow12{13    NSException *e = [NSException14                       exceptionWithName:@"JustForTheHeckOfItException"15                       reason:@"I felt like it"16                       userInfo:nil];17    @throw e;18    return 56;19}20 21- (int) iCatchMyself22{23  int return_value = 55;24  @try25    {26      return_value = [self callMeIThrow];27    }28  @catch (NSException *e)29    {30      return_value = 57;31    }32  return return_value;33}34@end35 36int37main ()38{39  int return_value;40  MyClass *my_class = [[MyClass alloc] init];41 42  NSLog (@"I am about to throw.");43 44  return_value = [my_class iCatchMyself];45 46  return return_value;47}48