3
我目前正在开发一款游戏,需要真正快速枚举数组。我需要每秒运行代码30次,现在想问什么是完成任务的最佳方式。 我想枚举一个数组并同时对其进行修改。快速枚举?
我知道2的时刻:
NSMutableArray*array;
int i=0;
int x=0;
for (myclass*spr in [[array copy] autorelease]) {
if ([spr isInBounds]) {
//do something
} else {
[array removeObjectAtIndex:x];
x--;
}
x++;
}
和
int x=0;
while(x<[array count])
{
if(![(myclass*)spr isInBounds]) {
[array removeObjectAtIndex:x];
x--;
}
x++;
}
什么是做到这一点的最快方法?你知道其他方法吗? 感谢您的帮助!
谢谢!这是我一直在寻找的东西! – user610246