zoukankan      html  css  js  c++  java
  • 获取字典中的数组

    #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;

    }

  • 相关阅读:
    Memo
    list查询记录时页面变成空白
    get the mail ids of the group members
    ui action(server side) change column value
    catalog item 时间按照指定形式输出
    select box 联动
    lookup select box和select box 联动
    函数二--递归
    函数一
    指针3
  • 原文地址:https://www.cnblogs.com/jidezhi/p/5120844.html
Copyright © 2011-2022 走看看