OC 数组、字典转换

 

//  从数组中检索 首字母相同的字符串

//    {

//        abs ,abac,

//         (b),

//         (cdc, cfr)

//    }


服务器接收参数

014-04-26 16:31:44.974 ZHRD[7389:60b] city    {

    hot =     (

        "\U70ed\U95e8-\U5e7f\U5dde\U5e02",

        "\U70ed\U95e8-\U6df1\U5733\U5e02",

        "\U70ed\U95e8-\U5317\U4eac\U5e02",

        "\U70ed\U95e8-\U4e0a\U6d77\U5e02"

    );

    other =     (

        "C-\U957f\U6c99\U5e02",

        "H-\U5408\U80a5\U5e02",

        "H-\U676d\U5dde\U5e02",

        "J-\U5409\U6797\U7701",

        "K-\U6606\U660e\U5e02",

        "L-\U4e3d\U6c5f\U5e02",

        "M-\U7261\U4e39\U6c5f\U5e02",

        "S-\U5341\U5830\U5e02",

        "S-\U6c55\U5934\U5e02",

        "T-\U5510\U5c71\U5e02",

        "T-\U5929\U6c34\U5e02",

        "T-\U5929\U6d25\U5e02",

        "Y-\U5cb3\U9633\U5e02",

        "Y-\U70df\U53f0\U5e02",

        "Z-\U6dc4\U535a\U5e02",

        "Z-\U91cd\U5e86\U5e02"

    );

}


    NSMutableDictionary *dicCity = [data JSONValue];

    NSMutableArray *arrHot = [dicCity objectForKey:@"hot"];

    NSMutableArray *arrOther = [dicCity objectForKey:@"other"];

    NSLog(@"city    %@",dicCity);

    NSMutableDictionary *dicData = [[NSMutableDictionary alloc]initWithCapacity:1];


    for (int i = 0; i < [arrOther count]; i++)

    {

        NSString *strOne = [arrOther objectAtIndex:i];

        NSMutableArray *arrData = [dicData objectForKey:[strOne substringToIndex:1]];

        if (!arrData)

        {

            arrData = [[NSMutableArray alloc]initWithCapacity:1];

            [ArrShouzimu addObject:[strOne substringToIndex:1]];

        }

        [arrData addObject:strOne];

        [dicData setObject:arrData forKey:[strOne substringToIndex:1]];

    }


//  打印字典 dicData

2014-04-26 16:31:44.978 ZHRD[7389:60b] {

    C =     (

        "C-\U957f\U6c99\U5e02"

    );

    H =     (

        "H-\U5408\U80a5\U5e02",

        "H-\U676d\U5dde\U5e02"

    );

    J =     (

        "J-\U5409\U6797\U7701"

    );

    K =     (

        "K-\U6606\U660e\U5e02"

    );

    L =     (

        "L-\U4e3d\U6c5f\U5e02"

    );

    M =     (

        "M-\U7261\U4e39\U6c5f\U5e02"

    );

    S =     (

        "S-\U5341\U5830\U5e02",

        "S-\U6c55\U5934\U5e02"

    );

    T =     (

        "T-\U5510\U5c71\U5e02",

        "T-\U5929\U6c34\U5e02",

        "T-\U5929\U6d25\U5e02"

    );

    Y =     (

        "Y-\U5cb3\U9633\U5e02",

        "Y-\U70df\U53f0\U5e02"

    );

    Z =     (

        "Z-\U6dc4\U535a\U5e02",

        "Z-\U91cd\U5e86\U5e02"

    );



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值