【发布时间】:2014-03-15 13:33:23
【问题描述】:
我的问题很简单:如何访问“matchs”字典并将其显示在 UITableView 中。
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self getCellContentView:CellIdentifier andIndexPath:indexPath];
NSArray *myArray = [contentDictio objectForKey:@"matchs"];
cell.textLabel.text = [[myArray objectAtIndex:indexPath.row]objectForKey:@"guest_team"];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
崩溃日志:-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x114a009c0
2014-03-15 14:34:18.127 01Foot[6089:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x114a009c0'
谢谢:-)
【问题讨论】:
-
在哪里初始化 contentDictio?请也分享该代码。
-
是 ->
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; path = [basePath stringByAppendingPathComponent:@"data-score.plist"]; arr = [[NSArray arrayWithContentsOfFile:path] mutableCopy]; contentDictio = [dict objectAtIndex: [[NSUserDefaults standardUserDefaults] integerForKey:@"index"]];
标签: uitableview nsdictionary plist unrecognized-selector