Warning message with detailed subviews?
Does my code look right? I'm trying to load data into my table view and detailed sub view. My table works fine, but the data wont load in my sub view
The 开发者_C百科warning appears under this line
nextController.dataItem = [data objectAtIndex:indexPath];
Here is my 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];
}
and my 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
It loads but I get the following warning:
"warning: passing argument 1 of 'objectAtIndex:' makes integer from pointer without a cast
The debugger says
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (64244544) beyond bounds (50)'
Any Ideas?
What Yannick said -- the "makes integer from pointer without a cast" means that you're using the address of the NSIndexPath object (which is probablly way more than the number of rows on your table, imagine the pointer points to 0x03030000 or something) as the row number and not the row field of the object.
精彩评论