1 #import <Foundation/Foundation.h>
3 @interface OverridesALot: NSObject
9 @implementation OverridesALot
16 + (id)allocWithZone: (NSZone *)z {
17 NSLog(@"allocWithZone:");
18 return [super allocWithZone: z];
41 - (BOOL)isKindOfClass: (Class)c {
42 NSLog(@"isKindOfClass:");
43 return [super isKindOfClass: c];
46 - (BOOL)respondsToSelector: (SEL)s {
47 NSLog(@"respondsToSelector:");
48 return [super respondsToSelector: s];
53 return [super retain];
56 - (oneway void)release {
62 NSLog(@"autorelease");
63 return [super autorelease];
72 @interface OverridesInit: NSObject
78 @implementation OverridesInit
90 // First make an object of the class that overrides everything,
91 // and make sure we step into all the methods:
93 obj = [OverridesALot alloc]; // Stop here to start stepping
94 [obj release]; // Stop Location 2
96 obj = [OverridesALot allocWithZone: NULL]; // Stop Location 3
97 [obj release]; // Stop Location 4
99 obj = [OverridesALot new]; // Stop Location 5
100 [obj release]; // Stop Location 6
102 obj = [[OverridesALot alloc] init]; // Stop Location 7
103 [obj self]; // Stop Location 8
104 [obj isKindOfClass: [OverridesALot class]]; // Stop Location 9
105 [obj respondsToSelector: @selector(hello)]; // Stop Location 10
106 [obj retain]; // Stop Location 11
107 [obj autorelease]; // Stop Location 12
108 [obj boring]; // Stop Location 13
109 [obj release]; // Stop Location 14
111 // Now try a class that only overrides init but not alloc, to make
112 // sure we get into the second method in a combined call:
114 obj = [[OverridesInit alloc] init]; // Stop Location 15
116 return 0; // Stop Location 15