NSRangeExceptionの謎を解くことができません。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_countyList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Inside masterview cellforrowatindexpath.\n");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.textLabel.text = [_countyList objectAtIndex:indexPath.row];
return cell;
}
例外は、1をnumberOfSectionsInTableView
返すとスローされます(1つのセクションがあるはずです)が、0のセクションを返すと、例外はスローされません(データも表示されません)。コードが実行されると、が呼び出されることはありませんcellForRowAtIndexPath
。デバッガーによってメイン関数に移動しますが、NSArrayにアクセスしている場所が一生わかりません。
ヘルプやデバッグのヒントをいただければ幸いです...