Skip navigation

Unrecognised selector sent to instance

1746 Views 20 Replies Latest reply: Apr 21, 2013 4:18 PM by etresoft RSS
1 2 Previous Next
Daz1761 Calculating status...
Currently Being Moderated
Apr 20, 2013 6:51 AM

I'm having problems with a tutorial I am watching on the UINavigationController and TableView. 

 

The link is here:

 

http://www.youtube.com/watch?v=vY8tQQn4evo

 

Everybody seems to be saying, great, thanks, worked perfectly, etc.  But everytime I try to implement about the first 10 mins of the video I get an unrecognised selector sent to instance 0x71788a0 to the UIViewController tableView: numberOfRowsInSection, which there clearly isn't a problem with as I've tried a new projects following the same proceedures.

 

I've tried relinking the table to files owner, all the usual troubleshootng tecniques and the same error is outputted.  The only thing differerent to all my other practice/tutorial projects is the way the ViewController and UINavigationController get loaded into the UIWindow:

 

 

#import "AppDelegate.h"

#import "ViewController.h"

 

 

@implementation AppDelegate

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // Override point for customization after application launch.

    UIViewController *viewController = [[UIViewController alloc] initWithNibName:@"ViewController" bundle:nil];

    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:viewController];

    self.window.backgroundColor = [UIColor whiteColor];

    self.window.rootViewController = navController;

    [self.window makeKeyAndVisible];

    return YES;

}

  • xnav Level 5 Level 5 (6,625 points)
    Currently Being Moderated
    Apr 20, 2013 8:05 AM (in response to Daz1761)

    Are you sure your method is defined exactly like this:

     

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    ...
    ...
    ...
    }
    
  • !# Level 1 Level 1 (0 points)
    Currently Being Moderated
    Apr 20, 2013 12:40 PM (in response to xnav)

    Actually I had the same issue when wrote "Rows" in lower case.  This error means, that you trying call method that doesn't exists.

  • xnav Level 5 Level 5 (6,625 points)
    Currently Being Moderated
    Apr 20, 2013 4:03 PM (in response to Daz1761)

    I don't think you added the VC correctly else the error message would say FirstViewController instead of UIViewController.

  • Michael Superczynski Level 5 Level 5 (7,105 points)
    Currently Being Moderated
    Apr 20, 2013 4:13 PM (in response to Daz1761)

    UIViewController doesn't respond to that method.

    You should be using a UITableViewController.

  • xnav Level 5 Level 5 (6,625 points)
    Currently Being Moderated
    Apr 20, 2013 4:14 PM (in response to Daz1761)

    My VC and .xib is named ViewController


    Then you are not following the tutorial and it's impossible for me to guess what you did and did not decide to do.

  • etresoft Level 7 Level 7 (23,905 points)
    Currently Being Moderated
    Apr 20, 2013 4:57 PM (in response to Daz1761)

    In Interface Builder you need to change the class name of your UIViewController instance to whatever your derived class (the one that implements tableView:numberOfRowsInSection:) is named.

  • xnav Level 5 Level 5 (6,625 points)
    Currently Being Moderated
    Apr 20, 2013 5:32 PM (in response to Michael Superczynski)

    Michael Superczynski wrote:

     

    UIViewController doesn't respond to that method.

    You should be using a UITableViewController.

    The tutorial uses a UIViewController.  It also shows how to connect the data source and delegate for the tableView so that the table methods can be in the VC.

  • xnav Level 5 Level 5 (6,625 points)
    Currently Being Moderated
    Apr 20, 2013 5:42 PM (in response to Daz1761)

    05:26 -> 05:56

  • Frank Caggiano Level 7 Level 7 (22,820 points)
    Currently Being Moderated
    Apr 20, 2013 6:42 PM (in response to Daz1761)

    You've defined the method

     

    tableView:numberOfRowsInSection:


    in the class ViewController but you are sending the message to UIViewController

1 2 Previous Next

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.