views:

129

answers:

1

Hello,

I Am creating an iPhone application which displays an UITableView at the start with some text in the cells. When a user taps a cell it should transition to another view. When I run the application in the iPhone Simulator and click on a cell I get the following error:

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: (

Here is the function (In RootViewController.m) where the error occurred. It happens at the

  if(self.eigenRisicoView == nil) {

line or the at the other if statements, depending on which cell you click.

    // 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];
    }

This is my RootControllerView.h file

#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

I Am new to iPhone development, Objective C and XCode so I don't understand what the error means..

Does anyone know what I am doing wrong?

+1  A: 

I'd need to see the whole implementation, but it sounds like you didnt @synthesize eigenRisicoView;

pzearfoss
That was the problem... Thank you :)
Rick