我的代码看起来正确吗?我正在尝试将数据加载到我的表格视图和详细的子视图中。我的表工作正常,但数据不会加载到我的子视图中
警告出现在此行下方
nextController.dataItem = [data objectAtIndex:indexPath];
这是我的 RootViewController.m
// Configure the data for the cell.
NSDictionary *dataItem = [data objectAtIndex:indexPath.row];
cell.icon = [UIImage imageNamed:[dataItem objectForKey:@"Icon"]];
cell.publisher = [dataItem objectForKey:@"Publisher"];
cell.name = [dataItem objectForKey:@"Name"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextView" bundle:nil];
nextController.dataItem = [data objectAtIndex:indexPath];
[self.navigationController pushViewController:nextController animated:YES];
[nextController release];
}
和我的 nextviewcontroller.h
#import <UIKit/UIKit.h>
@interface NextViewController : UIViewController
{
UILabel *nameLabel;
UIImageView *iconView;
NSDictionary *dataItem;
}
@property (nonatomic, retain) IBOutlet UILabel *nameLabel;
@property (nonatomic, retain) IBOutlet UIImageView *iconView;
@property (nonatomic, retain) NSDictionary *dataItem;
@end
它加载但我收到以下警告:
“警告:传递 'objectAtIndex:' 的参数 1 从指针生成整数而不进行强制转换
调试器说
由于未捕获的异常“NSRangeException”而终止应用程序,原因:“*** -[NSCFArray objectAtIndex:]: index (64244544) beyond bounds (50)”
有任何想法吗?