zoukankan      html  css  js  c++  java
  • 集合之间的相互转换

    //

    //  main.m

    //  11-集合相互转换

    //

    //  Created by apple on 14-3-21.

    //  Copyright (c) 2014年 apple. All rights reserved.

    //

    #import <Foundation/Foundation.h>

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

    {

        @autoreleasepool {

            

            //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);

            

        }

        return 0;

    }

  • 相关阅读:
    HDU
    HDU
    (4)数据--相似性与相异性
    (3)数据--操作
    (2)数据--基本概念
    五、按生命周期划分数据(二)
    五、常用数据类型(一)
    四、坏耦合的原因与解耦(三)
    四、强化耦合(二)
    四、初识耦合(一)
  • 原文地址:https://www.cnblogs.com/supper-Ho/p/6185706.html
Copyright © 2011-2022 走看看