码迷,mamicode.com
首页 > 其他好文 > 详细

OC中可变字典和不可变字典

时间:2015-07-27 09:31:05      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:字典   foundation框架   objective-c   存储对象   元素   

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    //不可改变字典,创建后不可改变
    
    NSDictionary * dic = [[NSDictionary alloc]initWithObjectsAndKeys:@"jack",@"name",@"18",@"age", nil];
    NSLog(@"%@",dic);
    NSDictionary * dic1 = @{@"name":@"jack",@"age":@"18"};
    NSLog(@"dic1 %@",dic1);
    
    NSNumber * num = [NSNumber numberWithInt:10];
    NSArray * array = @[@"one",@"two",@"three"];
    NSDictionary * dic2 = @{@"array":array,
                            @"num":num,
                            @"dic":dic
                            };
}
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSMutableDictionary * dic =
    [[NSMutableDictionary alloc]
     initWithObjectsAndKeys:@"Tom",@"name" ,@"20",@"age",nil];
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

OC中可变字典和不可变字典

标签:字典   foundation框架   objective-c   存储对象   元素   

原文地址:http://blog.csdn.net/u012701023/article/details/47079517

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!