Jace
Jace

Reputation: 397

Contextual type NSIndexSet cannot be used with array literal for Swift 2.x

I get the error in the 4th line below where I am trying to reload a section of the table. I also tried using NSMakeRange([indexPath.section], 1) but keep getting the same error.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        if (indexPath.section == 1) {
            isSectionSelected = true
            self.tableView.reloadSections([indexPath.section], withRowAnimation: .None)
            self.performSegueWithIdentifier("serviceHistoryDetailView", sender: self)
        }
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

Upvotes: 0

Views: 88

Answers (1)

rmaddy
rmaddy

Reputation: 318824

reloadSections expects an NSIndexSet, not an array of Int.

You need to create an NSIndexSet from indexPath.section. Then pass that NSIndexSet, not an array.

self.tableView.reloadSections(NSIndexSet(index: indexPath.section), withRowAnimation: .None)

Upvotes: 1

Related Questions