2010-02-21 61 views
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 

它加載但我得到以下警告:

「警告:傳遞的參數1 'objectAtIndex:' 將指針整數,未作鑄

調試器說

終止應用程序由於未捕獲的異常 'NSRangeException',究其原因: '*** - [NSCFArray objectAtIndex:]:index(64244544)beyond bounds(50)'

任何想法?

+1

在你的 - (空)的tableView:(UITableView的*)的tableView didSelectRowAtIndexPath方法:(NSIndexPath *)indexPath你犯了一個錯誤。 使用nextController.dataItem = [data objectAtIndex:indexPath.row]; – 2010-02-21 23:22:13

回答

0

Yannick說的 - 「使指針沒有轉換的整數」意味着你正在使用NSIndexPath對象的地址(這可能比你的表上的行數多,想象指針點到0x03030000什麼的)作爲行號而不是對象的行字段。

+0

多數民衆贊成它。發現。它加載沒有任何錯誤,當我點擊時不會崩潰。 雖然我的數據還沒有加載,但我仍然錯過了一些東西。我必須有一個挖掘周圍。再次感謝。 – user278342 2010-02-22 01:13:49