Apple/Classes

NSDictionary Code Examples

아침엔커피한잔 2017. 6. 12. 17:41

http://sharphail.tistory.com/65


    
/NSArray *old_ary = [NSArray arrayWithObjects:
                      [NSNumber numberWithInt:1],[NSNumber numberWithFloat:2.5f],[NSNumber numberWithBool:YES],nil];
NSArray *new_ary = @[@1,@2.5f,@YES];
NSLog(@"old_array : %@",[old_ary objectAtIndex:1]);
NSLog(@"new_array : %@",new_ary[1]);
 
NSDictionary *old_dic = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithInt:11],@"1st",
                         [NSNumber numberWithFloat:22.22f],@"2nd",
                         [NSNumber numberWithBool:NO],@"3rd",
                         [NSString stringWithFormat:@"4thString"],@"4th",
                         old_ary,@"5th",
                         nil];
NSDictionary *new_dic = @{@"1st": @11,
                          @"2nd": @22.22f,
                          @"3rd": @NO,
                          @"4th": @"4thString",
                          @"5th": new_ary};// === @"4th": @[@1,@2.5f,@YES]
NSLog(@"old_dic(count) : %d",[[old_dic objectForKey:@"5th"] count]);
NSLog(@"old_dic(count) : %d",[new_dic[@"5th"] count]);

/