mirkokiefer
mirkokiefer

Reputation: 3537

Setting NSMenuItem modifier in Swift 4 results in "Type of expression is ambiguous"

I'm trying to set the keyboard shortcut modifier of a NSMenuItem.

myMenuItem.keyEquivalentModifierMask = .shift | .command

But I'm getting an error "Type of expression is ambiguous without more context".

I wasn't able to find how to use this bit operator correctly in Swift.

Upvotes: 0

Views: 194

Answers (1)

Code Different
Code Different

Reputation: 93161

You are using the C-style bitwise or. In Swift it has been changed to an OptionSet:

myMenuItem.keyEquivalentModifierMask = [.shift, .command]

Upvotes: 2

Related Questions