iPhoneアプリプロジェクトに参加した後、アップデート後にデバッグすることになっています。客観的なcプログラマーではなく、どこから始めるべきかわかりません。どんな助けもありがとう。iOS NSRangeException、境界を越えたインデックス、NSMutableの配列
2011-07-07 15:27:44.333 App[5836:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 6 beyond bounds [0 .. 5]'
*** Call stack at first throw:
(
0 CoreFoundation 0x013d0be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x015255c2 objc_exception_throw + 47
2 CoreFoundation 0x013c66e5 -[__NSArrayM objectAtIndex:] + 261
3 CollegeFootballAlerts 0x00034892 -[SMStandings tableView:cellForRowAtIndexPath:] + 397
...
)
terminate called after throwing an instance of 'NSException'
ブレークポイントはここteamsInfo =である:ここ
デバッグ出力である- (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellIdentifier = @"TeamsInfoCell";
SMStandingsTableViewCell * cell = (SMStandingsTableViewCell *)[tableView1 dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
[[NSBundle mainBundle] loadNibNamed:@"SMStandingsTableViewCell" owner:self options:nil];
cell = standingsTableCell;
standingsTableCell = nil;
}
SMTeamsInfo * teamInfo;
NSMutableArray * teamsInGroup = [allGroups objectForKey:[allKeys objectAtIndex:indexPath.section]];
NSLog(@"TEAMS IN GROUP %@ :: %d", teamsInGroup, indexPath.row);
teamInfo = [teamsInGroup objectAtIndex:indexPath.row];
[[cell teamName] setText:[teamInfo nameEN]];
[[cell teamFlag] setImage:[teamInfo teamFlag]];
NSString * str;
if([segmentedControl selectedSegmentIndex] == 0) { // for conference tab wonconf - lostconf combination is used
str= [NSString stringWithFormat:@"%@",[teamInfo wonconf]];
str = [str stringByAppendingString:@"-"];
str = [str stringByAppendingFormat:@"%@",[teamInfo lostconf]];
}else { // for overall tab wonconf - lostconf combination is used
str= [NSString stringWithFormat:@"%@",[teamInfo wonall]];
str = [str stringByAppendingString:@"-"];
str = [str stringByAppendingFormat:@"%@",[teamInfo lostall]];
}
[[cell currentStanding ]setText:str];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
とnumberOfRowsInSection方法:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSArray * array = [allGroups allKeys];
NSLog(@"NO OF ROWS IN SECTION #%d : %d", section, [[allGroups objectForKey:[array objectAtIndex:section]] count]);
return [[allGroups objectForKey:[array objectAtIndex:section]] count];
}
とその方法の出力:
2011-07-08 17:46:13.837 App[7513:207] NO OF ROWS IN SECTION #1 : 7
2011-07-08 17:46:13.837 App[7513:207] NO OF ROWS IN SECTION #0 : 6
なぜセクション#1が最初に来るのかわかりません。行数は逆です。セクション0の場合は7、セクション1の場合は6で、問題の根本に似ているはずです。
に高すぎる数値を返すされている可能です。私はそれが起こった行に私を連れて行くことができますか? –
これはコードウィンドウで自動的に実行されます。実際にその半迷惑な。ない場合は、 –
が編集にブレークポイントを追加(三角形の中に感嘆符のXcode 4で左ペイン第四ボタンであれば)、エラー/警告リスト内のエラーをクリックしてみてください...それ以上はまだそれを行っていません。 –