Compilation error iOS Swift and reloadRowsAtIndexPaths

I got stuck using xCode / Swift and updated one line of a UITableView.

This line works ....

self.tableView.reloadData();

whereas this line is not

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

Autocomplete offers reloadRowsAtIndexPaths and gives syntax, but when compiling I get an error:

'Could not find element' reloadRowsAtIndexPaths'.

If I right-click and " jump to definition" in self.tableview, the character will not be found.

I hope that I am not doing anything embarrassing stupid here and will be grateful for the help. I could use reloadData, but want to know why this is not working here.

+4
source share
1 answer

, _currentIndexPath . -

var _currentIndexPath:NSIndexPath?

, :

if let indexPath = _currentIndexPath {
    self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
}
else {
    // `_currentIndexPath` is nil.
    // Error handling if needed.
}
+9

All Articles