0
我有这个while循环有点问题。我不断得到崩溃,因为它继续执行循环,即使它找到了对象并且据推测增加了int。 任何想法我有很多其他循环以类似的方式设置,他们都工作正常。while循环没有按给定的标准停止
int possible = 0;
while (possible < [possibleAthetes count]) {
if ([[[possibleAthetes objectAtIndex:possible]valueForKey:@"ID"]intValue] == [self.athleteID intValue]) {
[possibleAthetes removeObjectAtIndex:possible];
possible = [possibleAthetes count] ;
}
possible ++;
}
发布崩溃的堆栈跟踪。 – 2012-02-29 00:02:10
没有明显的原因坠机。然而,假设你只使用'possible'来控制循环,更直接的终止方法是改变'possible = [possibleAthetes];'到'break;''break'将终止封闭循环。 – CRD 2012-02-29 00:19:06
感谢帖子,在从这个问题上移动之后,我注意到这个循环并不是实际上的问题,但由于某种原因,Xcode在崩溃后突出显示了它。 – 2012-02-29 00:21:19