NSInvalidArgumentException

时间:2009-09-23 11:27:38

标签: iphone objective-c

我正在创建一个iPhone应用程序,它在开头显示一个UITableView,并在单元格中显示一些文本。当用户点击一个单元格时,它应该转换到另一个视图。当我在iPhone模拟器中运行应用程序并单击一个单元格时,我收到以下错误:

2009-09-23 12:20:03.554 ZDFMobiel[751:20b] *** Terminating app due to uncaught exception 
'NSInvalidArgumentException', reason: '*** -[RootViewController eigenRisicoView]:    
unrecognized selector sent to instance 0xd1d1a0'
2009-09-23 12:20:03.555 ZDFMobiel[751:20b] Stack: (

这是发生错误的函数(在RootViewController.m中)。它发生在

  if(self.eigenRisicoView == nil) { 

行或其他if语句,具体取决于您单击的单元格。

    // Override to support row selection in the table view.
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

 ZDFMobielAppDelegate *appDelegate = (ZDFMobielAppDelegate *)[[UIApplication sharedApplication] delegate];
 NSString *content = (NSString *)[appDelegate.menuItems objectAtIndex:indexPath.row];

 switch (indexPath.row) {
  case 0:
   if(self.eigenRisicoView == nil) {
    EigenRisicoViewController *viewController = [[EigenRisicoViewController alloc] initWithNibName:@"EigenRisicoViewController" bundle:[NSBundle mainBundle]];
    self.eigenRisicoView = viewController;
    [viewController release];
   }
   [self.navigationController pushViewController:self.eigenRisicoView animated:YES];
   self.eigenRisicoView.title = content;

   break;

  case 1:
   if(self.declaratieStatusView == nil) {
    DeclaratieStatusViewController *viewController = [[DeclaratieStatusViewController alloc] initWithNibName:@"DeclaratieStatusViewController" bundle:[NSBundle mainBundle]];
    self.declaratieStatusView = viewController;
    [viewController release];
   }
   [self.navigationController pushViewController:self.declaratieStatusView animated:YES];
   self.declaratieStatusView.title = content;

   break;

  case 2:
   if(self.vergoedingenView == nil) {
    VergoedingenViewController *viewController = [[VergoedingenViewController alloc] initWithNibName:@"VergoedingenViewController" bundle:[NSBundle mainBundle]];
    self.vergoedingenView = viewController;
    [viewController release];
   }
   [self.navigationController pushViewController:self.vergoedingenView animated:YES];
   self.vergoedingenView.title = content;

   break;

  case 3:
   if(self.zoekenZorgInstView == nil) {
    ZoekenZorgInstViewController *viewController = [[ZoekenZorgInstViewController alloc] initWithNibName:@"ZoekenZorgInstViewController" bundle:[NSBundle mainBundle]];
    self.zoekenZorgInstView = viewController;
    [viewController release];
   }
   [self.navigationController pushViewController:self.zoekenZorgInstView animated:YES];
   self.zoekenZorgInstView.title = content;

   break;
  default:
   break;
 }


    // Navigation logic may go here -- for example, create and push another view controller.
 // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
 // [self.navigationController pushViewController:anotherViewController animated:YES];
 // [anotherViewController release];
    }

这是我的RootControllerView.h文件

#import "EigenRisicoViewController.h";
#import "DeclaratieStatusViewController.h";
#import "VergoedingenViewController.h";
#import "ZoekenZorgInstViewController.h";
#import "ZDFMobielAppDelegate.h";

@interface RootViewController : UITableViewController {
 EigenRisicoViewController *eigenRisicoView;
 DeclaratieStatusViewController *declaratieStatusView;
 VergoedingenViewController *vergoedingenView;
 ZoekenZorgInstViewController *zoekenZorgInstView;

}

@property(nonatomic,retain) EigenRisicoViewController *eigenRisicoView;
@property(nonatomic,retain) DeclaratieStatusViewController *declaratieStatusView;
@property(nonatomic,retain) VergoedingenViewController *vergoedingenView;
@property(nonatomic,retain) ZoekenZorgInstViewController *zoekenZorgInstView;

@end

我是iPhone开发,Objective C和XCode的新手,所以我不明白这个错误是什么意思..

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:1)

我需要查看整个实现,但听起来你没有@synthesize eigenRisicoView;