I'm working on a mixed Objective-C / Swift macOS app.
I'm writing some code that checks the value returned from the selection key on an arrayController. NSArrayControllers return Any and normally I would check for multiple selection by seeing if the Any is a NSMultipleValuesMarker. However, writing this in Swift 3 I get the error:
Use of undeclared type 'NSMultipleValuesMarker'
The code I'm attempting is:
var selection = arrayController.value(forKeyPath: "selection.image")
if selection is NSMultipleValuesMarker {
// Do something for this case
}
I can't figure out what I'm missing to have NSMultipleValuesMarker available. I've tried importing Foundation, Cocoa and AppKit, but none of them seem to make the error go away.
'is' is the type check operator to check whether an instance is of a certain subclass type. Use selection === NSMultipleValuesMarker
to check if selection
is NSMultipleValuesMarker
.