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:]:インデックス(64244544)が境界(50)を超えています'

何か案は?

4

1 に答える 1

0

Yannickが言ったこと-「キャストなしでポインターから整数を作成する」とは、NSIndexPathオブジェクトのアドレスを使用していることを意味します(これはおそらくテーブルの行数よりもはるかに多いので、ポインターが0x03030000などを指していると想像してください) )オブジェクトの行フィールドではなく、行番号として。

于 2010-02-22T00:11:38.727 に答える