1 #import <Foundation/Foundation.h>
10 @interface SourceBase: NSObject
12 struct return_me my_return;
14 - (SourceBase *) initWithFirst: (int) first andSecond: (int) second;
15 - (void) randomMethod;
16 - (struct return_me) returnsStruct;
19 @implementation SourceBase
22 printf ("Called in SourceBase version of randomMethod.\n"); // SourceBase randomMethod start line.
25 - (struct return_me) returnsStruct
27 return my_return; // SourceBase returnsStruct start line.
30 - (SourceBase *) initWithFirst: (int) first andSecond: (int) second
32 my_return.first = first;
33 my_return.second = second;
39 @interface Source : SourceBase
43 - (void) setProperty: (int) newValue;
44 - (void) randomMethod;
45 - (struct return_me) returnsStruct;
48 @implementation Source
49 - (void) setProperty: (int) newValue
56 [super randomMethod]; // Source randomMethod start line.
57 printf ("Called in Source version of random method.");
60 - (struct return_me) returnsStruct
62 printf ("Called in Source version of returnsStruct.\n"); // Source returnsStruct start line.
63 return [super returnsStruct]; // Source returnsStruct call line.
68 @interface Observer : NSObject
72 + (Observer *) observerWithSource: (Source *) source;
73 - (Observer *) initWithASource: (Source *) source;
74 - (void) observeValueForKeyPath: (NSString *) path
76 change: (NSDictionary *) change
77 context: (void *) context;
80 @implementation Observer
82 + (Observer *) observerWithSource: (Source *) inSource;
86 retval = [[Observer alloc] initWithASource: inSource];
90 - (Observer *) initWithASource: (Source *) source
94 [_source addObserver: self
95 forKeyPath: @"property"
96 options: (NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
101 - (void) observeValueForKeyPath: (NSString *) path
102 ofObject: (id) object
103 change: (NSDictionary *) change
104 context: (void *) context
106 printf ("Observer function called.\n");
114 Observer *myObserver;
115 struct return_me ret_val;
117 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
119 mySource = [[Source alloc] init];
121 [mySource randomMethod]; // Set first breakpoint here.
122 ret_val = [mySource returnsStruct]; // Set second breakpoint here.
124 myObserver = [Observer observerWithSource: mySource];
126 [mySource randomMethod]; // Set third breakpoint here.
127 ret_val = [mySource returnsStruct]; // Set fourth breakpoint here.
128 [mySource setProperty: 5]; // Set fifth breakpoint here.
130 // We also had a bug where stepping into a method dispatch to nil turned
131 // into continue. So make sure that works here:
134 [mySource randomMethod]; // Set nil step breakpoint here.
135 [pool release]; // Step over nil should stop here.