これはちょうど私を狂わせようとしています。単純なグループ化されたテーブルを作成しようとしていますが、実行するたびに次のエラーが発生します。
-[__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance 0x489c
行をスローしているコードは次のとおりです(正確な行をアスタリスクで囲んでいます)。
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *newSpecCell = @"newSpecCell";
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSString *key = [segmentArray objectAtIndex:section];
NSArray *names = [specsDictionary objectForKey:key];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:newSpecCell];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:newSpecCell];
}
cell.textLabel.text = [names objectAtIndex:row]; // <---
return cell;
}
私のロジックobjectAtIndex
から、配列からを要求していますが、エラーはそれを定数文字列に送信していることを示しています。
私はいくつかのことを試しました(文字列を作成するなど[names objectAtIndex:row]
、違いはないようです。また、NSLogを使用して値を表示すると、names
正しく表示されるため、配列に必要な値が含まれていることがわかります。