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

Set

时间:2015-03-16 12:38:59      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

/*
 NSSet和NSArray的对比
 1> 共同点
 * 都是集合,都能存放多个OC对象
 * 只能存放OC对象,不能存放非OC对象类型(基本数据类型:int、char、float等,结构体,枚举)
 * 本身都不可变,都有一个可变的子类
 
 2> 不同点
 * NSArray有顺序,NSSet没有顺序
 */    

    NSSet *s = [NSSet set];
    NSSet *s2 = [NSSet setWithObjects:@"test1", @"test2",@"test3", @"test4", nil];
    NSString *str = [s2 anyObject];
    NSLog(@"%@", str);
    NSLog(@"%ld", s2.count);

    NSMutableSet *s = [NSMutableSet set];
    [s addObject:@"hack"];
    [s removeObject:@"hack"];

 

Set

标签:

原文地址:http://www.cnblogs.com/jsnan/p/4341267.html

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