我的代碼看起來不錯嗎?我試圖加載數據到我的表格視圖和詳細的子視圖。我的表工作正常,但數據在我的子畫面不會加載帶有詳細子視圖的警告消息?
出現這個
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
它加載但我得到以下警告:
「警告:傳遞的參數1 'objectAtIndex:' 將指針整數,未作鑄
調試器說
終止應用程序由於未捕獲的異常 'NSRangeException',究其原因: '*** - [NSCFArray objectAtIndex:]:index(64244544)beyond bounds(50)'
任何想法?
在你的 - (空)的tableView:(UITableView的*)的tableView didSelectRowAtIndexPath方法:(NSIndexPath *)indexPath你犯了一個錯誤。 使用nextController.dataItem = [data objectAtIndex:indexPath.row]; – 2010-02-21 23:22:13