Why is NSArrayController arrangedObjects returning an NSMutableIndexSet?

95 Views Asked by At

I have an NSTableView which calls my delegate. I am trying to customize the behavior of one my NSTableViewCells.

Upon starting the program, I can scroll through my tableView successfully. My "UsersController.arrangedObjects" should be castable to an array, but as soon as I select an item in my tableview, "UsersController.arrangedObjects" throws an exception because it is a

<NSMutableIndexSet: 0x600000d041b0>[number of indexes: 1 (in 1 ranges), indexes: (91)]

and not castable as an array.

I have programmed this feature in Objective-C and have never encountered this.

Thoughts?

extension AppDelegate: NSTableViewDelegate {
    func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {

        print("\(String.init(describing: UsersController.arrangedObjects))");
        guard let objects:[User] = UsersController.arrangedObjects as? [User] else {
            return nil
        }

        ...
    }
}
0

There are 0 best solutions below