iOS Swift and reloadRowsAtIndexPaths compilation error

10,071

I believe, _currentIndexPath is Optional. something like

var _currentIndexPath:NSIndexPath?

So try:

if let indexPath = _currentIndexPath {
    self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
}
else {
    // `_currentIndexPath` is nil.
    // Error handling if needed.
}
Share:
10,071
Fittoburst
Author by

Fittoburst

Updated on June 24, 2022

Comments

  • Fittoburst
    Fittoburst almost 2 years

    I've hit deadlock with xCode/Swift and refreshing a single row of UITableView.

    This line works....

    self.tableView.reloadData();
    

    whereas this line doesn't

    self.tableView.reloadRowsAtIndexPaths([_currentIndexPath], withRowAnimation: UITableViewRowAnimation.None);
    

    Auto-complete is suggesting reloadRowsAtIndexPaths and giving the syntax but on compilation, I'm getting the error:

    'Could not find member 'reloadRowsAtIndexPaths'.

    If I right click and 'jump to definition' in self.tableview, the symbol is not found.

    I'm hoping I'm not doing anything embarrassingly stupid here and would appreciate help. I could use reloadData but want to know why this isn't working here.