`.none` of `NSDragOperation` in Swift 3 is disappeared or not?

I can manage to use `NSDragOperation(rawValue: 0)` instead of `NSDragOperation.None`, because the latter is no more allowed in Swift 3.


However, when I set a break point, I found `.none` is still existing in the `let sourceDragMask = sender.draggingSourceOperationMask()` I got.


(lldb) print sourceDragMask
(NSDragOperation) $R0 = [.none, .copy, .link, .generic, .move, .delete]


So, is `.none` disappeared or not? Or is this a bug that Swift 3 can't use `.none` but the SDK can tansfer a `.none`?


macOS Sierra 10.12 (16A323), Xcode 8.0 (8A218a).

Accepted Reply

The ".None" case of Swift 2 was renamed to ".none" in Swift 3. It represents a raw value of 0, meaning no options are in the set.


Additionally, the ".none" case is now marked "unavailable", to reduce confusion about whether ".none" and "[ ]" mean the same thing. So, the debugger is correct in showing ".none" as one of the OptionsSet elements, and the compiler is correct in preventing you from using it.


I believe there are a few Obj-C enums in the SDK that are imported where the case with raw value 0 is still available. These are enums where that case has some semantics other than just "no options". I can't find the place where this was documented or discussed — it might have been in one of the swift.org forums.


Edit: Use an empty array literal ("[ ]") instead of "NSDragOperation(rawValue: 0)".

Replies

The ".None" case of Swift 2 was renamed to ".none" in Swift 3. It represents a raw value of 0, meaning no options are in the set.


Additionally, the ".none" case is now marked "unavailable", to reduce confusion about whether ".none" and "[ ]" mean the same thing. So, the debugger is correct in showing ".none" as one of the OptionsSet elements, and the compiler is correct in preventing you from using it.


I believe there are a few Obj-C enums in the SDK that are imported where the case with raw value 0 is still available. These are enums where that case has some semantics other than just "no options". I can't find the place where this was documented or discussed — it might have been in one of the swift.org forums.


Edit: Use an empty array literal ("[ ]") instead of "NSDragOperation(rawValue: 0)".

Thank you very much!