此代码导致应用程序崩溃!我正在循环查看字典,并且一切都很顺利。它的工作原理,当我在for循环而不是其他写-1,重新加载表崩溃应用程序
-(void)updateProjectTimes {
for(int i = 0; i < [projectsTable numberOfRowsInSection:0]-1; i++) {
NSString *currentValue = [[[projects objectForKey:@"activeProjects"] objectAtIndex:i] objectForKey:@"timepassed"];
NSString *finishValue = [[[projects objectForKey:@"activeProjects"] objectAtIndex:i] objectForKey:@"timeleft"];
if([currentValue intValue] < [finishValue intValue]) {
[[[projects objectForKey:@"activeProjects"] objectAtIndex:i] setObject:[NSString stringWithFormat:@"%d", ([currentValue intValue] + 1)] forKey:@"timepassed"];
} else {
[(NSMutableArray *)[projects objectForKey:@"activeProjects"] removeObjectAtIndex:i];
if([[projects objectForKey:@"activeProjects"] count] == 0) {
[projectTimer invalidate];
projectTimer = nil;
}
}
//[projectsTable reloadData]; works if i put it here!
}
[projectsTable reloadData]; //<- But not here!! :(
}
你的错误是什么? – Emil 2012-01-11 21:23:01
发布崩溃日志,无法从您的代码中知道。 [编辑评论时,并没有注意到你开始时对'-1'的引用。在代码中会有更清晰的评论。 – XJones 2012-01-11 21:47:49