错误:读取在“TableItem *”类型的对象上找不到的数组元素的预期方法

时间:2016-04-17 18:48:57

标签: ios objective-c uitableview

- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath ];
    TableItem *item = self.items[indexPath.section][indexPath.row];
    cell.textLabel.text = item.title;
    cell.detailTextLabel.text = item.description;
}

错误:在此行上读取未在“TableItem *”类型的对象上找到的数组元素的预期方法:TableItem *item = self.items[indexPath.section][indexPath.row];

TableItem.h

#import <Foundation/Foundation.h>

@interface TableItem : NSObject

@property (weak,nonatomic) NSString *title;
@property (weak,nonatomic) NSString *description;

-(instancetype) initWithTitle: (NSString *) title description: (NSString *) description;

@end

1 个答案:

答案 0 :(得分:0)

尝试

TableItem *item = self.items[indexPath.row];

而不是

TableItem *item = self.items[indexPath.section][indexPath.row];

我假设是self.items是TableItem对象的数组。