NSArray、NSMutableArray相关

2016-02-29  本文已影响0人  FeelYoung
NSMutableArray* a = ...
NSMutableArray* b = [a mutableCopy];
for (id obj in b) {
    [a removeObject:obj];
}```
- 遍历数组的常用的三种方式
   for循环

NSArray* a = ...
for (int i=0; i<a.count; i++) {
...
}

   增强for

NSArray* a = ...
for (id obj in a) {
...
}

   迭代器

NSArray* a = ...
NSEnumerator* enumerator = [a objectEnumerator];
id obj = nil;
while (id = [enumerator nextObject]) {
...
}

上一篇下一篇

猜你喜欢

热点阅读