#import <Foundation/Foundation.h>

 

int main(int argc, const char * argv[]) {

    @autoreleasepool {

 

    NSNumber *num=[NSNumber numberWithInt:100];

        

    NSDictionary *dic=[NSDictionary dictionaryWithObject:num  forKey:@"money"];

    

    NSDictionary *dics=[NSDictionary dictionaryWithObjectsAndKeys:@"Jay",@"name",@"22",@"age",@"F",@"gender",nil];

    NSDictionary *dic1=@{@"name":@"White",

                         @"age":@"23",

                         @"gender":@"M"};

    NSDictionary *dic2=[NSDictionary dictionaryWithDictionary:dic1];

        NSLog(@"%@",dic);

    //key-value共有多少对

        NSInteger count=[dic2 count];

        NSLog(@"count=%ld",count);

    //获取字典内value值

        NSString *name=[dic2 objectForKey:@"name"];

        NSLog(@"根据key找value--姓名:%@",name);

    //获取字典内所有的value

        NSArray *values=[dic2 allValues];

        for (id str in values) {

            NSLog(@"%@",str);

        }

    //获取字典内所有的key

        NSArray *keys=[dic2 allKeys];

        for (id str in keys) {

            NSLog(@"%@",str);

        }

    }

    return 0;

}

 

posted on 2016-01-11 17:00  哦呵呵呵哦  阅读(173)  评论(0编辑  收藏  举报