NSSet NSMutableSet的简单使用

 //创建一个带多个参数的

    NSSet *set=[NSSet setWithObjects:@"hello",@"hai", nil];

    /*

     所有 [set allObjects];

     随机一个 [set anyObject];

     */

    NSLog(@"set===%@",[set allObjects]);

    

    //创建一个可变的Set

    NSMutableSet *set2=[NSMutableSet set];

    //添加元素

  //  [set2 addObject:@"hello"];

    [set2 addObjectsFromArray:@[@"hello",@"hai"]];

    //移除指定元素

    [set2 removeObject:@"hello"];

    //移除所有

    //[set2 removeAllObjects];

    NSLog(@"%@",[set2 allObjects]);

原文地址:https://www.cnblogs.com/zhuzhushen/p/4285384.html