tableview ne fonctionne pas - [UIViewController tableView: numberOfRowsInSection:]: sélecteur non reconnu envoyé à l'instance

Je suis en train de l'init d'un uitableview à l'aide de xib mais quand je lance l'application dans le simulateur, le ci-dessous exception est levée.

2013-06-16 10:40:48.552 CoreDataExample[60661:c07] -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x81765a0
2013-06-16 10:40:48.554 CoreDataExample[60661:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x81765a0'

Ci-dessous les étapes que j'ai suivi du démarrage de la tableview:

  1. Ajouter UITableViewDelegate et UITableViewDataSource dans mon viewController.
  2. Insérer le tableview en vue dans mon viewController.xib.
  3. Créer datasource et delegate en il fichiers du propriétaire (en appuyant sur la touche contrôle enfoncée et en faisant glisser la souris en bas du composant propriétaire du fichier et en sélectionnant l'option délégué par exemple).
  4. Mettre en œuvre les méthodes - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section et - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath dans mon viewController.m.

Ci-dessous la mise en œuvre de deux méthodes:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 10;

}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = nil;

    static NSString *identifier = @"identifier";

    cell = [tableView dequeueReusableCellWithIdentifier:identifier];

    if(cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    }

    cell.textLabel.text = @"Olá";
    cell.detailTextLabel.text = @"Subtitle" ;
    [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];


    return cell;
}

ViewController.h ci-dessous:

@interface CDEMainViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

@end

source d'informationauteur Alessandro Garcez