main.m revision 9b3117e0365f3a3d59cf9adc073f716cea3bf942
1//===-- main.m ------------------------------------------------*- ObjC -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#import <Foundation/Foundation.h> 11 12@interface MyClass : NSObject 13{ 14 int i; 15 char c; 16 float f; 17} 18 19- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z; 20- (int)doIncrementByInt: (int)x; 21 22@end 23 24@interface MyOtherClass : MyClass 25{ 26 int i2; 27 MyClass *backup; 28} 29- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q; 30 31@end 32 33@implementation MyClass 34 35- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z 36{ 37 self = [super init]; 38 if (self) { 39 self->i = x; 40 self->f = y; 41 self->c = z; 42 } 43 return self; 44} 45 46- (int)doIncrementByInt: (int)x 47{ 48 self->i += x; 49 return self->i; 50} 51 52@end 53 54@implementation MyOtherClass 55 56- (id)initWithInt: (int)x andFloat:(float)y andChar:(char)z andOtherInt:(int)q 57{ 58 self = [super initWithInt:x andFloat:y andChar:z]; 59 if (self) { 60 self->i2 = q; 61 self->backup = [[MyClass alloc] initWithInt:x andFloat:y andChar:z]; 62 } 63 return self; 64} 65 66@end 67 68int main (int argc, const char * argv[]) 69{ 70 71 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 72 73 // insert code here... 74 NSLog(@"Hello, World!"); 75 76 MyClass *object = [[MyClass alloc] initWithInt:1 andFloat:3.14 andChar: 'E']; 77 78 [object doIncrementByInt:3]; 79 80 MyOtherClass *object2 = [[MyOtherClass alloc] initWithInt:2 andFloat:6.28 andChar: 'G' andOtherInt:-1]; 81 82 [object2 doIncrementByInt:3]; 83 // Set break point at this line. 84 [pool drain]; 85 return 0; 86} 87 88