views:

93

answers:

1

Does my code look right? Im 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 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? thanks

A: 

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.

corprew
thats it guys. spot on. It loads without any errors and doesnt crash when i click.Though my data still doesnt load, i must have still missed somthing. Ill have to have a dig around. Thanks again.