I am trying to convert an old Objective C Macintosh application to Swift, and have been pulling my hair out for days with what seems like a simple problem. I need some help connecting the sorting functionality of NSTableView with my Swift Array.
I have a swift class called "Employee" that has a number of instance variables and calculated, "read-only" fields. I have another swift struct called "Employees" that includes among other things a hidden [Employee] array called "contents".
I've added the sequence and collection protocols to my Employees class, so all of that is working well. I also implemented the sorting routines shown in the SwiftbySundell article which work fine. My Employees class is displayed via NSTableView, which also works fine. Here is my question. How do I implement
tableView(_ tableView: NSTableView, sortDescriptorsDidChange oldDescriptors: [NSSortDescriptor])
in Swift? The Apple Documentation for NSTableView isn't helpful, since it hasn't been updated for Swift at all. My sorting routines work, but I don't know how to bridge between the NSSortDescriptors coming from the table and the Swift sortdescriptors in my code. I can't be the first one to do this, and the objectiveC solution was just three lines of code... is there a good example out there somewhere showing how this is done?
Thank you!!
Selecting any option will automatically load the page