0

我的代码看起来正确吗?我正在尝试将数据加载到我的表格视图和详细的子视图中。我的表工作正常,但数据不会加载到我的子视图中

警告出现在此行下方

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)”

有任何想法吗?

4

1 回答 1

0

Yannick 所说的 - “从没有强制转换的指针中生成整数”意味着您正在使用 NSIndexPath 对象的地址(这可能比表上的行数多,想象指针指向 0x03030000 或其他东西) 作为行号而不是对象的行字段。

于 2010-02-22T00:11:38.727 回答