> On Fri, Jun 17, 2016 at 9:33 PM, Maury Markowitz via swift-users
> <[email protected]> wrote:
> I was asked to try out the latest betas of Cocoa to check if a SceneKit bug I
> reported has been fixed. As part of this I decided to try an update to Swift
> 3. I've run into a number of minor issues, but one has me frustrated. In my
> menu validate method, I have:
>
> switch menuItem.action {
> case #selector!(showRescale) :
>
> This worked fine in 2.2, but now it complains that it expects a ( after
> #selector. Removing the ! fixes that problem, but now returns an error that
> there's a missing !, which it inserts to cause the original error again. I
> also tried placing it after the ()'s, and now it complains that it's
> expecting the :
>
> Does anyone know the proper Swift 3 syntax for this?
This code snippet works for me in a menu validation function...
guard let action = anItem?.action else { return false }
switch action {
case #selector(showOpenPanel(_:)):
return true
case #selector(save(_:)):
return modified
case #selector(openPreferencesWindow(_:)):
return true
default:
print("default for item \(anItem)")
}
return false
I used the guard let... to get around the fact that action selectors are now
optionals.
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users