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

集合相互转换

时间:2015-01-01 08:57:58      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

        //1.NSArray 转换成 NSMutableArray
        NSArray * array = @[@"one",@"two",@"three"];
        NSMutableArray * muArray = [NSMutableArray arrayWithArray:array];
        NSLog(@"muarray %@",muArray);
        
        //2.NSDictonary 转换成        NSMutableDictionary
        NSDictionary * dic = @{@"one":@"1",@"two":@"2"};
        NSMutableDictionary * muDic = [NSMutableDictionary dictionaryWithDictionary:dic];
        NSLog(@"mudic %@ ",muDic);
        
        //3.NSset 转换成 NSMutableSet
        NSSet * set = [[NSSet alloc] initWithObjects:@"one",@"two", nil];
        NSMutableSet *muSet = [NSMutableSet setWithSet:set];
        NSLog(@"muSet %@",muSet);
        
        
        //4.NSArray 转换成NSSet
        NSMutableSet * muSet2 = [NSMutableSet setWithArray:array];
        NSLog(@"muSet2 %@",muSet2);
        
        
        //5.NSDictionary 转化成NSArray
        NSArray * allkeys = [dic allKeys];
        NSLog(@"allkeys %@",allkeys);
        NSArray * allValues = [dic allValues];
        NSLog(@"allValues %@",allValues);
        
        //6.字符串转换成数组
        NSString * str = @"www.itacast.cn";
        NSArray * strArray =        [str componentsSeparatedByString:@"."];
        NSLog(@"strArray %@",strArray);

 

集合相互转换

标签:

原文地址:http://www.cnblogs.com/cwhking/p/4197003.html

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