このコードは、アプリケーションをクラッシュさせます。私は辞書をループしていて、すべてが正常にログアウトします。私はforループではなく、そうでない場合には-1を書くときには、私はあなたがtableView
でwokringされていると仮定しReloadTableアプリケーションがクラッシュする
-(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
クラッシュログを投稿してください。あなたのコードからはわかりません。 [コメントを編集し、最初に '-1 'への参照を気付かなかった。コード内のコメントで明確になります。 – XJones