首页 > 技术文章 > iOS NSMutableArray替换某个元素

sun-wsh 2016-08-11 17:49 原文

1 A * a1 = [A new];
2 A * a2 = [A new];
3 A * a3 = [A new];
4 A * a4 = [A new];
5 NSMutableArray *arr = [[NSMutableArray alloc]initWithArray:@[a1,a2,a3]];
6 [MyArr replaceObjectAtIndex:0 withObject:a4];

结果 MyArr = @[a4,a2,a3];

推荐阅读