tableViewSelectionDidChange does not work in Xcode 8

1

After upgrading to the Sierra macOS, and consequently to Xcode 8, the tableViewSelectionDidChange function no longer works. I think my code is correct.

func tableViewSelectionDidChange(_ notification: Notification) {

        if let selectedRow = (notification.object as AnyObject).selectedRow {
            if ( selectedRow > -1 ) {
                selectedItem = data[selectedRow]
                if let nome = selectedItem?.value(forKey: "nome") as? String {
                    nomeField.stringValue = nome
                } else {
                    blankOutField(nomeField)
                }


    override func viewDidLoad() {
        super.viewDidLoad()
        let appDelegate = NSApplication.shared().delegate as! AppDelegate
        managedContext = appDelegate.managedObjectContext
        tableView.delegate = self
        tableView.dataSource = self
        fetchDataAndRefreshTable()
    }

    func fetchDataAndRefreshTable() {
        let fetchRequest = NSFetchRequest<NSFetchRequestResult> (entityName: "CadastroPacientes")
        let sortDescriptor = NSSortDescriptor(key: "nome", ascending: true, selector: #selector(NSString.localizedStandardCompare(_:)))
        fetchRequest.sortDescriptors = [sortDescriptor]
        do {
            data = try managedContext!.fetch(fetchRequest) as! [NSManagedObject]
        } catch {
            Swift.print(error)
        }
    }

I can not find the solution because it looks like the line is not selected, nothing happens when I click on the line in TableView .

The program is using Core Data, but everything worked perfectly.

    
asked by anonymous 30.09.2016 / 22:31

0 answers