Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numberOfSectionsInTableView not called

In my ViewController, i have an UITableView and these methods :

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if(self.mQuoteObjects.count > 0){
        return 1
    }
    return 0

}


func tableView(tableView: UITableView, numberOfSectionsInTableView section: Int) -> Int {
    let nbItem = self.mQuoteObjects.count
    return nbItem

}

Method "numberOfRowsInSection" is correctly called, but "numberOfSectionsInTableView" is never called.

What have i missed?

You can respond in Obj-c

like image 227
Kevin ABRIOUX Avatar asked Apr 22 '15 16:04

Kevin ABRIOUX


1 Answers

The name of the method is not correct. It should be numberOfSectionsInTableView(_:).

See the UITableViewDataSource protocol reference.

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return self.mQuoteObjects.count
}
like image 52
Marcos Crispino Avatar answered Sep 27 '22 21:09

Marcos Crispino