// // main.m // ObjectiveCTest3 // // Created by UEC on 30/12/15. // Copyright (c) 2015¦~ uec. All rights reserved. // #import int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Objective C Data Structure"); // String handling NSString *myname = [[NSString alloc]initWithFormat:@"David Wong"]; NSString *mytel = [[NSString alloc]initWithFormat:@"99993433"]; NSLog(@"My name is %@ and my phone is %@",myname,mytel); NSString *myemail = @"davidwong@eee.com"; NSLog(@"My email is %@",myemail); if([mytel isEqualToString:@"999333993"]) { NSLog(@"Equal"); } else { NSLog(@"Not Equal"); } // Array handling (Number -> Value) NSArray *myclass = [[NSArray alloc]initWithObjects:@"Peter",@"Mary",@"Sam",nil]; NSLog(@"The first student is %@",[myclass objectAtIndex:0]); NSLog(@"The 3rd student is %@",[myclass objectAtIndex:2]); NSArray *myclass2 = @[@"David",@"Tony",@"Peter"]; NSLog(@"The 2nd student is %@",myclass2[1]); // Dictionary handling (Key -> Value) NSDictionary *mydict= [[NSDictionary alloc]initWithObjectsAndKeys:@"Peter",@"1st student",@"Sam",@"2nd student",@"Mary",@"3rd student", nil]; NSLog(@"The 1st student is %@",[mydict objectForKey:@"1st student"]); NSDictionary *mydict2 = @{@"1st student":@"Peter",@"2nd student":@"Mary",@"3rd student":@"Tony"}; NSLog(@"The 2nd student is %@",mydict2[@"2nd student"]); } return 0; }