diff options
| author | mo khan <mo@mokhan.ca> | 2013-05-14 18:37:00 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-05-14 18:37:00 -0600 |
| commit | a6def661856bc8f0c0a51519fc50a37a3cbf5bf3 (patch) | |
| tree | 74658d8ff2c2213fc99665fcb9fd0e1621668af1 /2013-05-07 | |
| parent | 368fa097f326613c326b76cc648d78330eb7544d (diff) | |
use an array in the people example
Diffstat (limited to '2013-05-07')
| -rw-r--r-- | 2013-05-07/People/People.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate | bin | 14627 -> 14929 bytes | |||
| -rw-r--r-- | 2013-05-07/People/People/Person.h | 1 | ||||
| -rw-r--r-- | 2013-05-07/People/People/domain/Human.m (renamed from 2013-05-07/People/People/Human.m) | 0 | ||||
| -rw-r--r-- | 2013-05-07/People/People/main.m | 18 |
4 files changed, 18 insertions, 1 deletions
diff --git a/2013-05-07/People/People.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate b/2013-05-07/People/People.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate Binary files differindex ff9664e..df374bf 100644 --- a/2013-05-07/People/People.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate +++ b/2013-05-07/People/People.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/2013-05-07/People/People/Person.h b/2013-05-07/People/People/Person.h index bf1911e..7c16dfd 100644 --- a/2013-05-07/People/People/Person.h +++ b/2013-05-07/People/People/Person.h @@ -11,6 +11,7 @@ @interface Person : NSObject @property (strong, nonatomic) NSString * firstName; @property (strong, nonatomic) NSString * lastName; +@property int age; -(NSString *)putFirstAndLastTogether:(NSString *)first; -(NSString *)fullName; -(NSString *)theTruth; diff --git a/2013-05-07/People/People/Human.m b/2013-05-07/People/People/domain/Human.m index 214c3e3..214c3e3 100644 --- a/2013-05-07/People/People/Human.m +++ b/2013-05-07/People/People/domain/Human.m diff --git a/2013-05-07/People/People/main.m b/2013-05-07/People/People/main.m index 60a0de5..e307c19 100644 --- a/2013-05-07/People/People/main.m +++ b/2013-05-07/People/People/main.m @@ -8,7 +8,7 @@ #import <Foundation/Foundation.h> #import "Person.h" -#import "Human.m" +#import "domain/Human.m" int main(int argc, const char * argv[]) { @@ -25,6 +25,22 @@ int main(int argc, const char * argv[]) NSLog(@"%@", [person tellMeSomethingIDontKnow]); [person change:@"Mo" last_name:@"Ka" age:29]; NSLog(@"%@", [person tellMeSomethingIDontKnow]); + + NSArray * firstNames = [[NSArray alloc] initWithObjects:@"hi", nil]; + NSArray * lastNames = [[NSArray alloc] initWithObjects:@"hi", nil]; + NSArray * ages = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:25], [NSNumber numberWithInt:18], [NSNumber numberWithInt:32], [NSNumber numberWithInt:40], [NSNumber numberWithInt:62], nil]; + + NSMutableArray *people = [[NSMutableArray alloc]init]; + Person *newGuy = [[Person alloc] init]; + + for (int i = 0; i < [firstNames count]; i++) { + newGuy.firstName = [firstNames objectAtIndex:i]; + newGuy.lastName = [lastNames objectAtIndex:i]; + newGuy.age = [[ages objectAtIndex:i] intValue]; + + [people addObject:newGuy]; + NSLog(@"%@ %@ %d", [[people objectAtIndex:i] firstName], [[people objectAtIndex:i] lastName], [[people objectAtIndex:i] age]); + } Human * human = [Human new]; |
