1 #import <Foundation/Foundation.h> 2 3 @interface MyClass : NSObject { 4 int member; 5 } 6 7 - (id)initWithMember:(int)_member; 8 - (NSString*)description; 9 @end 10 11 @implementation MyClass 12 13 - (id)initWithMember:(int)_member 14 { 15 if (self = [super init]) 16 { 17 member = _member; 18 } 19 return self; 20 } 21 22 - (void)dealloc 23 { 24 [super dealloc]; 25 } 26 27 // Set a breakpoint on '-[MyClass description]' and test expressions: expr member 28 - (NSString *)description 29 { 30 return [NSString stringWithFormat:@"%d", member]; 31 } 32 @end 33 34 int main (int argc, char const *argv[]) 35 { 36 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 37 38 MyClass *my_object = [[MyClass alloc] initWithMember:5]; 39 40 NSLog(@"MyObject %@", [my_object description]); 41 42 [pool release]; 43 return 0; 44 } 45