0
votes
  1. I have drag the tableview into a view controller.
  2. i have created an outlet property to the table .

    @property (strong, nonatomic) IBOutlet UITableView *tableView;

  3. i have added the delegate in the interface

    UITableViewDelegate

    4.registered the delegate with :
    tableView.delegate=self;

and added all functions of a tableview, that usually did worked before :

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

And all the others. the functions are not being called at start.

What am i missing here ?

2
They are Data Source Methods, not Delegate Methods. - Larme
I made this mistake a couple of times. Sooner or later you learn to recognize the symptom. (If all else fails, carefully review the specs.) - Hot Licks

2 Answers

1
votes

You are missing the tableView's dataSource. These methods appear on the dataSource, not the delegate.

Set tableView.dataSource=self; as well, and you should be good to go.

UITableView has two delegates delegate and dataSource as they handle different areas of focus.

0
votes

You may be missing one of the following things.

1.Make sure you have set your datasource and delegate of your TableView as your current view controller by Xibs or by code.

2.Do mention your protocal that you have to implement in header of your like below.

@interface ViewController()<UITableViewDataSource,UITableViewDelegate>