NSString NSArray NSDictionary NSSet 中的部分方法

来源:互联网 发布:centos 6.5 squid 编辑:程序博客网 时间:2024/04/30 05:20

NSString NSArray NSDictionary NSSet 中的部分方法


   
    
    //1、init
    //    NSString  *s1 = [[NSString alloc]init];
    
    //2、initWithBytes:length:encoding:
    //    NSString *s2 = [[NSString alloc] initWithBytes:@"aaaa" length:2 encoding:NSUTF8StringEncoding];
    //
    
    //3、initWithCharacters:length:
    //    NSString *s3 = [[NSString alloc]initWithCharacters:"e" length:2];
    
    //    4、initWithCString:encoding:   以标准形式输出  输出汉字  与10对应
    //    NSString *s4 = [[NSString alloc]initWithCString:"aaaa" encoding:NSUTF8StringEncoding];
    //
    //    NSLog(@"%@",s4);
    
    
    //    5、initWithUTF8String:  //将字符串转化为oc的字符串格式
    //    NSString *s5 = [[NSString alloc]initWithUTF8String:"abcde"];
    //    NSLog(@"%@",s5);
    
    //    6、initWithFormat:   //对象初始化     retaincount = 1
    //    NSString *s6 = [[NSString alloc] initWithFormat:@"%d",123];
    
    //    7、stringWithFormat:   //便利构造器
    //    NSString *s7 = [NSString stringWithFormat:@"%d",5550];
    
    //    8、stringWithCharacters:length:
    //    NSString *s8 = [NSString stringWithCharacters:@"aaa" length:4];
    
    //    9、stringWithString:   直接打印  与3对应   retaincount = -1
    //    NSString *s9 = [NSString stringWithString:@"abcd"];
    
    //    10、stringWithCString:encoding:
    
    //    NSString *s10 = [NSString stringWithCString:"aaa" encoding:NSUTF8StringEncoding];
    //    NSLog(@"%@",s10);
    
    //    11、stringWithUTF8String:  与5对应
    //    NSString *s5 = [NSString stringWithUTF8String:"abcde"];
    //    NSLog(@"%@",s5);
    
    //    12、length   求字符串长度
    //    NSString *s7 = [NSString stringWithFormat:@"%d",5550];
    //    NSLog(@"%ld",(unsigned long)[s7 length]);
    
    //    13、lengthOfBytesUsingEncoding:  同12   就是打印
    //    NSString *s7 = [NSString stringWithFormat:@"%d",5550];
    //    int long  length2 = [s7 lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
    //    NSLog(@"length2 = %ld ",length2);
    
    //    14、characterAtIndex:  取当前指定字符下标的字符
    //    NSString *s7 = [NSString stringWithFormat:@"%d",5550];
    //    char a = [s7 characterAtIndex:2];
    //    NSLog(@"%c",a );
    
    //    15、getCharacters:range:   去第几个值 取几个 存到一个数组中
    //    NSString *s1 = [NSString stringWithFormat:@"%@",@"abcdefg"];
    //    unichar a[10];
    //    NSRange range = NSMakeRange(4, 2);
    //    [s1 getCharacters:a range:range];
    //输出数组a
    
    
    //    16、cStringUsingEncoding:  转化成c 类型的字符串
    //    NSString *s2 =[NSString stringWithFormat:@"%@",@"abcdefg"];
    //    const char *s1 = [s2 cStringUsingEncoding:NSUTF8StringEncoding];
    //
    //    NSLog(@"%s",s1);
    
    //    17、UTF8String
    //    NSString *s2 =[NSString stringWithFormat:@"%@",@"abcdefg"];
    //    const char *s1 = [s2 UTF8String];
    //    NSLog(@"%s",s1);
    
    //    18、stringByAppendingFormat:字符串的追加  追加单个字符
    //    NSString *s2 =[NSString stringWithFormat:@"%@",@"abcdefg"];
    //    NSString *s3 = [s2 stringByAppendingFormat:@"A"];
    
    //    19、stringByAppendingString:字符串的追加
    //    NSString *s2 =[NSString stringWithFormat:@"%@",@"abcdefg"];
    //    NSString *s3 = [s2 stringByAppendingString:@"AAAAAAAAA"];
    
    
    //    20、stringByPaddingToLength:withString:startingAtIndex:  从下表开始追加什么 追加几个
    //    NSString *s2 =[NSString stringWithFormat:@"%@",@"abc"];
    //    NSString *s3 = [s2 stringByPaddingToLength:9 withString:@"." startingAtIndex:0];
    //    NSLog(@"%@",s3);
    
    //    21、componentsSeparatedByString:  以某个字符分开字符串
    //    NSString *s2 =[NSString stringWithFormat:@"a bc"];
    //    NSArray  *ar1 =[s2 componentsSeparatedByString:@" "];
    //    NSLog(@"%@",ar1);
    
    
    
    //    22、componentsSeparatedByCharactersInSet:
    //    NSString *s2 =[NSString stringWithFormat:@"%@",@"a bc"];
    //    NSArray  *ar1 =[s2 componentsSeparatedByCharactersInSet];
    
    //    23、substringFromIndex   求子字符串  从第几个开始取  一直取到最后
    //    NSString *s = [NSString stringWithFormat:@"abcde"];
    //    NSString *s1 = [s substringFromIndex:2];
    
    //    24、substringWithRange:
    //    NSString *s = [NSString stringWithFormat:@"abcde"];
    //    NSString *s1 = [s substringWithRange:NSMakeRange(0, 4)];
    //    NSLog(@"%@",s1);
    
    //    25、substringToIndex: 求子字符串  从0 开始取   一共去几个
    //    NSString *s = [NSString stringWithFormat:@"abcde"];
    //    NSString *s1 = [s substringFromIndex:2];
    
    //    26、rangeOfString:  从开始找字符串  输出range
    //    NSString *str7 = [[NSString alloc]initWithFormat:@"%s","bin ing"];
    //    NSRange r1 = [str7 rangeOfString:@"in"];
    //    NSLog(@"%lu,%lu",r1.location,r1.length);
    
    //    27、rangeOfString:options:  从后面开始找
    //    NSString *str7 = [[NSString alloc]initWithFormat:@"%s","bining"];
    //    NSRange r2 = [str7 rangeOfString:@"in" options:NSBackwardsSearch];
    //    NSLog(@"%lu,%lu",r2.location,r2.length);
    
    //    28、rangeOfString:options:range:从一段范围内开始找
    
    
    //    29、stringByReplacingOccurrencesOfString:withString:   用字符串代替字符创
    
    //    NSString *str7 = [[NSString alloc]initWithFormat:@"%s","bining"];
    //    NSString *s =[str7 stringByReplacingOccurrencesOfString:@"in" withString:@"**"];
    //    NSLog(@"%@",s);
    
    // 不懂   30、stringByReplacingOccurrencesOfString:withString:options:range:
    //    NSString *str7 = [[NSString alloc]initWithFormat:@"%s","binin8inininig"];
    //    NSLog(@"%@",[str7 stringByReplacingOccurrencesOfString:@"in" withString:@"**" options:NSAnchoredSearch range:NSMakeRange(0, 13)]);
    
    //    31、stringByReplacingCharactersInRange:withString:  范围内的字符串被替代为  字符串
    //    NSString *str7 = [[NSString alloc]initWithFormat:@"%s","binin8inininig"];
    //    NSString *str =  [str7 stringByReplacingCharactersInRange:NSMakeRange(0, 3) withString:@"*"];
    //    NSLog(@"%@",str);
    
    
    
    //    32、caseInsensitiveCompare:   比较两个字符创输出枚举值  升  为1 降  -1
    //    NSString *str7 = [[NSString alloc]initWithFormat:@"%s","a"];
    //    NSInteger NSComparisonResult = [str7 caseInsensitiveCompare:@"b"];
    //    NSLog(@"%ld",(long)NSComparisonResult);
    
    //    33、compare:两个字符串的比较
    //    NSInteger NSComparisonResult = [@"a" compare:@"b"];
    //    NSLog(@"%ld",(long)NSComparisonResult);
    
    
    
    //    34、compare:options:   从后往前比较  字符串大小
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"arfgaerwf"];
    //    NSString *s2 = [[NSString alloc]initWithFormat:@"bdfs"];
    //    NSInteger NSComparisonResult = [s1 compare:s2 options:NSBackwardsSearch];
    //    NSLog(@"%ld",(long)NSComparisonResult);
    
    //    35、compare:options:range:
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"arfgaerwf"];
    //    NSString *s2 = [[NSString alloc]initWithFormat:@"bdfs"];
    //    NSInteger NSComparisonResult = [s1 compare:s2 options:NSBackwardsSearch range:NSMakeRange(0, 2)];
    //    NSLog(@"%ld",(long)NSComparisonResult);
    
    
    //    36、hasPrefix:  是否有前缀
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"arfgaerwf"];
    //    NSInteger b1 = [s1 hasPrefix:@"a"];
    
    
    //    37、hasSuffix:是否有后缀
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"arfgaerwf"];
    //    NSInteger b1 = [s1 hasSuffix:@"a"];
    
    //    38、isEqualToString:
    
    //    39、capitalizedString    首字母大写
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"arfgaerwf"];
    //    NSLog(@"%@",[s1 capitalizedString]);
    
    //    40、lowercaseString     所有小写
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"AAAfgaerwf"];
    //    NSLog(@"%@",[s1 lowercaseString]);
    
    //    41、uppercaseString   所有大写
    //    NSString *s1 = [[NSString alloc]initWithFormat:@"AAAfgaerwf"];
    //    NSLog(@"%@",[s1 uppercaseString]);
    
    //    42、doubleValue
    //    NSLog(@"%lf",[@"12.3" doubleValue]);
    
    //    43、floatValue
    //    NSLog(@"%lf",[@"12.3" floatValue]);
    
    //    44、intValue
    //    NSLog(@"%d",[@"123" intValue]);
    
    //    45、integerValue
    //    NSLog(@"%ld",(long)[@"12.3" integerValue]);
    
    //    46、longLongValue
    //    NSLog(@"%lld",[@"12.3" longLongValue]);
    
    //    47、boolValue
    //    NSLog(@"%d",[@"12.3" boolValue]);
    //
    
    //       NSMutableString  可变字符串
    
    
    
    //    48、stringWithCapacity:  创建一个字符串,容量为size大小
    //    NSMutableString *s1 = [NSMutableString stringWithCapacity:3];
    
    
    //    49、initWithCapacity:  初始化一个字符串,容量为size
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithCapacity:3];
    
    //    50、appendFormat:   增加一个字符串
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"qqq"];
    //    [s1 appendFormat:@"!!!!"];
    //    NSLog(@"%@",s1);
    
    
    //    51、appendString:
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"qqq"];
    //    [s1 appendString:@"!!!!"];
    //    NSLog(@"%@",s1);
    
    //    52、deleteCharactersInRange:删除一个范围类的
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"abcdefg"];
    //    [s1 deleteCharactersInRange:NSMakeRange(2, 4)];
    //    NSLog(@"%@",s1);
    
    
    //    53、insertString:atIndex:在下标插入字符串
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"abcdefg"];
    //    [s1 insertString:@"222" atIndex:2];
    //    NSLog(@"%@",s1);
    
    //    54、replaceCharactersInRange:withString:  在某个范围内用某字符串取代
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"abcdefguyu"];
    //    [s1 replaceCharactersInRange:NSMakeRange(2, 5) withString:@"***"];
    //    NSLog(@"%@",s1);
    
    //    55、replaceOccurrencesOfString:withString:options:range:
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"efefefguyu"];
    //    [s1 replaceOccurrencesOfString:@"ef" withString:@"*" options:NSBackwardsSearch range:NSMakeRange(3,5)];
    //    NSLog(@"%@",s1);
    
    //    56、setString:  用后面的字符串取代前面面
    //    NSMutableString *s1 = [[NSMutableString alloc] initWithFormat:@"abcdefguyu"];
    //    [s1 setString:@"QfgQ"];
    //    NSLog(@"%@",s1);
    //
    //
    //    1、array
    //    NSArray *a1 = [NSArray array];
    
    //    2、arrayWithArray:  用数组初始化另外一个数组
    //    NSArray *a1 = [NSArray array];
    //    NSArray *a2 = [NSArray arrayWithArray:a1];
    
    //    3、arrayWithObject:  初始化  一个数组元素
    //    NSArray *a2 = [NSArray arrayWithObject: @"1"];
    
    //    4、arrayWithObjects:
    //    NSArray *a1 = [NSArray arrayWithObjects: @"1",@"2",nil];
    
    //    5、arrayWithObjects:count:  取一个数组里面的几个元素   同9
    //    id a[3] = {@"1",@"2",@"3"};
    //    NSArray *a1 = [NSArray arrayWithObjects:a count:2];
    //    NSLog(@"%@",a1);
    
    //    6、init
    //    NSArray *a1 = [[NSArray alloc]init];
    
    //    7、initWithArray:   用数组初始化另外一个数组
    //    NSArray *a1 = [[NSArray alloc]init];
    //    NSArray *a2 = [[NSArray alloc]initWithArray:a1];
    
    //    8、initWithObjects:
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2" ,nil];
    
    //    9、initWithObjects:count:   取一个数组里面的几个元素   同5
    //    id a[3] = {@"1",@"2",@"3"};
    //    NSArray *a1 = [[NSArray alloc] initWithObjects:a count:2];
    //    NSLog(@"%@",a1);
    
    //    10、containsObject://  数组中是否包含某元素
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    int bo  = [a1 containsObject:@"1"];
    
    //    11、count   计算数组的元素个数
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    int long a = [a1 count];
    //    NSLog(@"%ld",a);
    
    //    12、getObjects:range:      去一个范围内的元素存储到一个数组中
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    id a [10] ;
    //    [a1 getObjects:a range:NSMakeRange(0, 3)];
    //    NSLog(@"%@",a[2]);
    
    //    13、firstObject  第一个元素  (wu)
    
    //    14、lastObject   z最后一个元素
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSArray *a2 =  [a1 lastObject];
    //    NSLog(@"%@",a2);
    
    //    15、objectAtIndex:    指定下表元素]
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSLog(@"%@",[a1 objectAtIndex:1]);
    
    //    16、objectsAtIndexes:   不懂
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSIndexSet *indexset = [NSIndexSet indexSetWithIndex:0];
    //    NSArray *a2 = [a1 objectsAtIndexes:indexset];
    //    NSLog(@"%@",a2);
    
    //    17、objectEnumerator    枚举
    
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSEnumerator *enu = [a1 objectEnumerator];
    //
    //    id obj;
    //    while (obj = [enu nextObject]) {
    //        NSLog(@"obj:%@",obj);
    //    }
    
    
    //    18、reverseObjectEnumerator    反向枚举
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSEnumerator *enu = [a1 reverseObjectEnumerator];
    
    //    19、indexOfObject:  //返回指定元素的下标
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSLog(@"%lu",(unsigned long)[a1 indexOfObject:@"1"]);
    
    //    20、indexOfObject:inRange:///在一个范围内找指定元素的下标
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    ;
    //    NSLog(@"%ld",[a1 indexOfObject:@"1" inRange:NSMakeRange(1, 3)]);
    
    //    21、makeObjectsPerformSelector:通过某方法对数组排序
    //    NSArray *arr = [NSArray arrayWithObjects:@"3",@"2",@"1", nil];
    //
    //    [arr makeObjectsPerformSelector:<#(SEL)#>];
    
    
    //    22、makeObjectsPerformSelector:withObject:
    
    //    23、firstObjectCommonWithArray:   返回另外一个数组与当前数组第一个相同的元素
    //    NSArray *a1 = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",nil];
    //    NSArray *arr = [NSArray arrayWithObjects:@"2",@"2",@"1", nil];
    //    ;
    //    NSLog(@"%@",[arr firstObjectCommonWithArray:a1]);
    
    //    24、isEqualToArray:   比较两个数组  返回bool值
    
    
    //    NSMutableString
    
    //    25、arrayByAddingObject:   给一个数组增加一个元素
    //    NSMutableArray *a1= [NSMutableArray arrayWithObjects:@"1",@"2",@"3", nil];
    //    NSArray *a2 = [a1 arrayByAddingObject:@"4"];
    //    NSLog(@"%@",a2);
    
    //    26、arrayByAddingObjectsFromArray:  从另外一个数组增加元素
    //    NSArray *a1= [NSArray arrayWithObjects:@"1",@"2",@"3", nil];
    //    NSArray *a2= [NSArray arrayWithObjects:@"4", nil];
    //    NSArray *a3 = [a1 arrayByAddingObjectsFromArray:a2];
    //    NSLog(@"%@",a3);
    
    //    27、sortedArrayUsingFunction:context:  按照某个方法来进行排序
    //    NSArray *a = [NSArray arrayWithObjects:@"Apple",@"IBM",@"Microsoft", nil];
    //    NSArray *orderArray = [a sortedArrayUsingFunction:NSOrderedAscending context:NULL];
    //    NSLog(@"%@",orderArray);
    
    //    28、sortedArrayUsingDescriptors:   这里的NSArray中的第一元素表示首先按照这个元素的升序或者降序进行排序,对于有重复项的,再按照第二元素进行排序,依次进行类推
    //    NSDictionary *_dic1=[NSDictionary dictionaryWithObjectsAndKeys:@"2030",@"year", @"1",@"month",nil];
    //    NSDictionary *_dic2=[NSDictionary dictionaryWithObjectsAndKeys:@"2010",@"year", @"2",@"month", nil];
    //    NSDictionary *_dic3=[NSDictionary dictionaryWithObjectsAndKeys:@"2050",@"year", @"3",@"month" ,nil];
    //    NSDictionary *_dic4=[NSDictionary dictionaryWithObjectsAndKeys:@"2014",@"year",  @"4",@"month",nil];
    //    NSDictionary *_dic5=[NSDictionary dictionaryWithObjectsAndKeys:@"2050",@"year",  @"4",@"month",nil];
    //    NSArray *_array=[NSArray arrayWithObjects:_dic1,_dic2,_dic3,_dic4,_dic5, nil];
    //
    //    NSSortDescriptor *descripor=[NSSortDescriptor sortDescriptorWithKey:@"year" ascending:NO];
    //
    //    NSSortDescriptor *descripor2=[NSSortDescriptor sortDescriptorWithKey:@"month" ascending:NO];
    //
    //    [_array sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descripor,descripor2,nil]];
    //
    //    NSLog(@"%@",[_array sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descripor,descripor2,nil]]);
    
    //    29、sortedArrayUsingSelector:   按照某方法来进行排序
    
    
    //    30、componentsJoinedByString:   用某个字符连接成一个字符串  拼接
    //    NSArray *a1= [NSArray arrayWithObjects:@"1",@"2",@"3", nil];
    //    NSString *a2 = [a1 componentsJoinedByString:@"-"];
    //    NSLog(@"%@",a2);
    //
    //    31、arrayWithCapacity:   便利构造器初始化数组
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    
    //    32、initWithCapacity:   alloc初始化可变数组
    //    NSMutableArray *arr1 = [[NSMutableArray alloc]initWithCapacity:4];
    
    //    33、addObject:增加一个对象
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr addObject:@"5"];
    
    //    34、addObjectsFromArray:   从一个数组中增加对象  即增加后面的数组
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    NSMutableArray *arr2 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr addObjectsFromArray:arr2];
    
    //    35、insertObject:atIndex:    在索引值插入元素
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr insertObject:@"5" atIndex:2];
    
    //    36、removeAllObjects   删除所有的元素
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr removeAllObjects];
    
    //    37、removeLastObject   删除最后一个元素
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr removeLastObject];
    
    //    38、removeObject:      删除与后面相同的元素
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr removeObject:@"4"];
    
    ////    39、removeObject:inRange:     删除指定范围的 元素
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr removeObject:@"2" inRange:NSMakeRange(0, 4)];
    
    //    40、removeObjectAtIndex:     删除指定下标的元素
    //    NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
    //    [arr removeObjectAtIndex:3];
    
    //    41、removeObjectsInArray:    删除一个在其他数组中的对象
    //    NSMutableArray *a1 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",nil];
    //    NSMutableArray *a2 = [NSMutableArray arrayWithObjects:@"1",nil];
    //    [a1 removeObjectsInArray:a2];
    //    NSLog(@"%@",a1);
    
    //    42、removeObjectsInRange:在某个范围内删除对象
    //    NSMutableArray *a2 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",nil];
    //    [a2 removeObjectsInRange:NSMakeRange(0, 1)];
    
    //    43、replaceObjectAtIndex:withObject:  下标为几 的用后面的元素取代
    //    NSMutableArray *a2 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",nil];
    //    [a2 replaceObjectAtIndex:2 withObject:@"4"];
    
    //    44、setArray:   重置一个数组
    //     NSMutableArray *a1 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",nil];
    //    NSMutableArray *a2 = [[NSMutableArray alloc]init];
    //    [a1 setArray:a2];
    //
    
    //    45、exchangeObjectAtIndex:withObjectAtIndex:  交换两小\标的元素
    //    NSMutableArray *a2 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",nil];
    //    [a2 exchangeObjectAtIndex:2 withObjectAtIndex:3];
    
    //    46、sortUsingDescriptors:
    //    NSMutableArray
    //    47、sortUsingFunction:context:
    //    48、sortUsingSelector:
    
    
    
    
    //字典
    
    //    1、dictionary
    //    NSDictionary *d = [NSDictionary dictionary];
    
    //    2、dictionaryWithDictionary:
    //    NSDictionary *d1 = [NSDictionary dictionary];
    //    NSDictionary *d = [NSDictionary dictionaryWithDictionary:d1];
    
    //    3、dictionaryWithObject:forKey:
    //    NSDictionary *d = [NSDictionary dictionaryWithObject:@"tzs" forKey:@"name"];
    
    //    4、dictionaryWithObjects:forKeys:
    //    NSArray *value = @[@"tzs",@"m",@"24"];
    //    NSArray *key = @[@"na me",@"sex",@"age"];
    //    NSDictionary *d1 = [NSDictionary dictionaryWithObjects:value forKeys:key];
    
    //    5、dictionaryWithObjectsAndKeys:   算是比较常用
    //    NSDictionary *d3 = [NSDictionary dictionaryWithObjectsAndKeys:@"xiaobao",@"name",@"m",@"sex", nil];
    
    //    6、initWithDictionary:
    //    NSDictionary *d3 = [NSDictionary dictionaryWithObjectsAndKeys:@"xiaobao",@"name",@"m",@"sex", nil];
    //    NSDictionary *d4 = [[NSDictionary alloc] initWithDictionary:d3];
    
    //    7、initWithObjects:forKeys:
    //    NSArray *value = @[@"tzs",@"m",@"24"];
    //    NSArray *key = @[@"na me",@"sex",@"age"];
    //
    //    NSDictionary *d = [[NSDictionary alloc]initWithObjects:value forKeys:key];
    
    //    8、initWithObjectsAndKeys:
    //    NSDictionary *d = [[NSDictionary alloc] initWithObjectsAndKeys:@"name",@"age",@"sex", nil];
    
    //    9、count
    //    NSDictionary *d3 = [NSDictionary dictionaryWithObjectsAndKeys:@"xiaobao",@"name",@"m",@"sex", nil];
    //    NSLog(@"%ld",[d3 count]);
    
    //    10、isEqualToDictionary:
    //    NSDictionary *d3 = [NSDictionary dictionaryWithObjectsAndKeys:@"xiaobao",@"name",@"m",@"sex", nil];
    //    NSArray *value = @[@"tzs",@"m",@"24"];
    //    NSArray *key = @[@"na me",@"sex",@"age"];
    //    NSDictionary *d1 = [NSDictionary dictionaryWithObjects:value forKeys:key];
    //    int a = [d1 isEqualToDictionary:d3];
    
    //    11、allKeys  打印所有的键
    //    12、allKeysForObject: 打印某个值对应的所有的键  返回值为数组
    //    13、allValues  返回所有的 值
    //    14、objectForKey:   查找key  对应的 value
    //    NSArray *value = @[@"tzs",@"m",@"24"];
    //    NSArray *key = @[@"name",@"sex",@"age"];
    //    NSDictionary *d1 = [NSDictionary dictionaryWithObjects:value forKeys:key];
    //    NSLog(@"%@" ,[d1 objectForKey:@"name"]);
    
    //    15、valueForKey:同  14  只不过
    
    //    16、keyEnumerator
    //    NSDictionary *d = [NSDictionary dictionaryWithObject:@"tzs" forKey:@"name"];
    //    NSEnumerator *e = [d  keyEnumerator];
    //    id obj;
    //    while (obj = [e nextObject]) {
    //        NSLog(@"obj:%@",obj);
    //    }
    
    
    //    17、objectEnumerator
    //    NSDictionary *d = [NSDictionary dictionaryWithObject:@"tzs" forKey:@"name"];
    //    NSEnumerator *e = [d  objectEnumerator];
    //    id obj;
    //    while (obj = [e nextObject]) {
    //        NSLog(@"obj:%@",obj);
    //    }
    
    //    18、keysSortedByValueUsingSelector:  通过某个方法对字典的key排序
    
    
    //    可变字典
    
    //    19、dictionaryWithCapacity:初始化
    //    NSMutableDictionary *d = [NSMutableDictionary dictionaryWithCapacity:3];
    
    //    20、initWithCapacity:
    //    NSMutableDictionary *d = [[NSMutableDictionary alloc]initWithCapacity:3];
    //    21、init
    //    22、setObject:forKey:
    //    NSMutableDictionary *d = [[NSMutableDictionary alloc]initWithCapacity:3];
    //   [d setObject:@"tzs" forKey:@"name"];
    //    NSLog(@"%@",d);
    
    //    23、setValue:forKey:
    
    //    24、setDictionary:
    //    NSMutableDictionary *d = [[NSMutableDictionary alloc]initWithCapacity:3];
    //    NSMutableDictionary *d2 = nil ;
    //    [d2 setDictionary:d];
    
    //    25、removeObjectForKey:
    //    NSArray *value = @[@"tzs",@"m",@"24"];
    //    NSArray *key = @[@"name",@"sex",@"age"];
    //
    //    NSMutableDictionary *d = [NSMutableDictionary dictionaryWithObjects:value forKeys:key];
    //    [d removeObjectForKey:@"name"];
    
    //    26、removeAllObjects
    //    27、removeObjectsForKeys:
    //    NSArray *value = @[@"tzs",@"m",@"24"];
    //    NSArray *key = @[@"name",@"sex",@"age"];
    //
    //    NSMutableDictionary *d = [NSMutableDictionary dictionaryWithObjects:value forKeys:key];
    //    NSArray *a = @[@"name",@"sex"];
    //    [d removeObjectsForKeys:a];
    //    NSLog(@"%@",d);
    //
    //
    //
    //    1、set
    //    2、setWithArray:
    //    NSArray *a = @[@"1",@"2"];
    //    NSSet *s = [NSSet setWithArray:a];
    //    NSLog(@"%@",s);
    
    //    3、setWithObject:
    
    //    NSSet *s = [NSSet setWithObject:@"1"];
    
    //    4、setWithObjects:
    //    NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    
    //    5、setWithSet:   用另外一个初始化
    
    //    6、setByAddingObject:增加
    //    NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSSet *s1 = [s setByAddingObject:@"4"];
    
    //    7、setByAddingObjectsFromSet:
    //    NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSSet *s1 = [NSSet setWithObject:@"4", nil];
    //    NSSet *s2 = [s setByAddingObjectsFromSet:s1];
    //    8、setByAddingObjectsFromArray:  增加一个数组的元素到集合
    //    9、count
    //     NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSLog(@"%ld",[s count]);
    //    10、allObjects
    //    NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSLog(@"%@",[s allObjects]);
    //    11、anyObject   随机取一个元素
    //    12、containsObject:
    //    13、member:    查找是否有相同元素  有则返回 灭有返回空
    //    NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSLog(@"%@",[s member:@"3"]);
    //    14、objectEnumerator   枚举u
    //    NSSet *s = [NSSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSEnumerator *en = [s objectEnumerator];
    //    id obj ;
    //    while (obj = [en nextObject]) {
    //        NSLog(@"s = %@",obj);
    //    }
    //    15、isSubsetOfSet:   判断是否有子集
    //    16、intersectsSet:   判断是否有交集
    //    17、isEqualToSet:    判断是否相同
    //
    //
    //    可变集合
    //
    //    18、addObject:       增加一个元素
    //    19、removeObject:     删减一个元素
    //    20、removeAllObjects   删除所有元素
    //    21、addObjectsFromArray:   从数组中增加元素
    //    22、unionSet:    合并两个集合
    //    NSMutableSet *s = [NSMutableSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSMutableSet *s2 = [NSMutableSet setWithObjects:@"4",@"2",@"5", nil];
    //    [s unionSet:s2];
    //    NSLog(@"%@",s);
    
    //    23、minusSet:     减去相同元素的集合
    //    NSMutableSet *s = [NSMutableSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSMutableSet *s2 = [NSMutableSet setWithObjects:@"4",@"2",@"5", nil];
    //    [s minusSet:s2];
    //    NSLog(@"%@",s);
    
    //    24、intersectSet:   两个集合 的交集
    //    NSMutableSet *s = [NSMutableSet setWithObjects:@"1",@"2",@"3", nil];
    //    NSMutableSet *s2 = [NSMutableSet setWithObjects:@"4",@"2",@"5", nil];
    //    [s intersectSet:s2];
    //    NSLog(@"%@",s);
    
    //    25、setSet:用一个集合重置一个集合
    //  
    
    
    //    26、countForObject:
    //    NSCountedSet *s = [NSCountedSet setWithObjects:@"1",@"2",@"1",nil];
    //    NSLog(@"%ld",[s countForObject:@"1"]);
    

0 0