1 | #import <Foundation/Foundation.h> |
2 | |
3 | @interface MyException : NSException |
4 | { |
5 | int ; |
6 | } |
7 | - (NSException *) initWithExtraInfo: (int) info; |
8 | @end |
9 | |
10 | @implementation MyException |
11 | - (NSException *) initWithExtraInfo: (int) info |
12 | { |
13 | [super initWithName: @"NSException" reason: @"Simple Reason" userInfo: nil]; |
14 | self->extra_info = info; |
15 | return self; |
16 | } |
17 | @end |
18 | |
19 | int |
20 | main(int argc, char **argv) |
21 | { |
22 | // Set a breakpoint here for plain exception: |
23 | @try { |
24 | NSException *plain_exc = [[NSException alloc] initWithName: @"NSException" reason: @"Simple Reason" userInfo: nil]; |
25 | [plain_exc raise]; |
26 | } |
27 | @catch (id anException) {} |
28 | |
29 | // Set a breakpoint here for MyException: |
30 | @try { |
31 | MyException *my_exc = [[MyException alloc] initWithExtraInfo: 100]; |
32 | [my_exc raise]; |
33 | } |
34 | @catch (id anException) {} |
35 | |
36 | return 0; |
37 | } |
38 | |