うれしげに、@property で DataRow を作って見た例。
もうちょっと整理しないと。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | /* clang -o main4 main4.m -I /llvm/include -I /GNUstep/GNUstep/System/Library/Headers -L c:/GNUstep/GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString -Wno-format-security */ #import <stdio.h> #import <Foundation/Foundation.h> #import <Foundation/NSObject.h> @interface Person : NSMutableDictionary { @private int _id ; NSString *_name; int _age ; } @property ( nonatomic ) int id ; @property ( nonatomic ,retain) NSString *name; @property ( nonatomic ) int age ; @end @implementation Person @synthesize id = _id ; @synthesize name = _name ; @synthesize age = _age ; - ( void )print { NSLog ( @"%d %@(%d)" , _id, _name, _age ); } - (Person*)initWithId:( int ) id Name:( NSString *)name Age:( int )age { _id = id ; _name = name; _age = age; return self ; } @end @interface Persons : NSObject { @private NSMutableArray *_rows ; } @property ( nonatomic ,retain) NSMutableArray *rows ; @end @implementation Persons @synthesize rows = _rows; - ( id )init { [ super init]; _rows = [[ NSMutableArray alloc] init]; return self ; } - ( void )print { for ( int i=0; i< [_rows count]; i++ ) { Person *p = [_rows objectAtIndex:i]; [p print]; } } @end int _main( int argc, char *argv[]) { Person *masuda = [[Person alloc] initWithId:1 Name: @"masuda" Age:40]; Person *yamada = [[Person alloc] initWithId:2 Name: @"yamada" Age:50]; Person *tanaka = [[Person alloc] initWithId:3 Name: @"tanaka" Age:20]; Persons *persons = [[Persons alloc] init]; [persons.rows addObject:masuda]; [persons.rows addObject:yamada]; [persons.rows addObject:tanaka]; [persons print]; return 0; } int main( int argc, char *argv[]) { NSAutoreleasePool *pool = [[ NSAutoreleasePool alloc] init]; int retVal = _main(argc, argv); [pool release]; return retVal; } |