美文网首页
NSMutalbleArray

NSMutalbleArray

作者: 哔哩哔哩智能喵 | 来源:发表于2016-08-22 18:59 被阅读54次
   NSMutableArray * arrM = [NSMutableArray array];
                //添加元素
                [arrM addObject:@"xc"];
                //将制定数组中的元素都取出来,放到arrM中 xc yf xxx
                [arrM addObjectsFromArray:@[@"yf",@"xxx"]];
                
                //将元素插入到数组的某个索引
                [arrM insertObject:@"lp" atIndex:1];
                
                NSRange range = NSMakeRange(1, 2);
                NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:range];
                //插入一组数据,制定数组需要插入的位置和插入多少
                [arrM insertObjects:@[@"a",@"b"] atIndexes:set];
                //删除数组中的元素
                [arrM removeObject:@"b"];
        //        [arrM removeObjectAtIndex:2];
                //替换数组中的元素
                [arrM replaceObjectAtIndex:1 withObject:@"L"];
                //获取数组中的元素
                [arrM objectAtIndex:0];
        

相关文章

网友评论

      本文标题:NSMutalbleArray

      本文链接:https://www.haomeiwen.com/subject/yidgsttx.html