问题描述:

My goal is to create a MacOS app that will run some security tests and display the result in a TableView. For each failing test, I want the user to be able to click on a "Fix!" button.

I tried to do this using Cocoa Bindings and Swift 3 on Xcode 8. It seems to work, but I cannot set the button to perform the selector I want.

I followed this example that I tried to adapt to swift: https://developer.apple.com/library/mac/samplecode/BoundButton/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004366-I…

I can get everything working, but when I click on the button I get the following error:

2016-09-13 13:23:20.978223 SampleCocoaBinding[31429:1142008]

-[SampleCocoaBinding.TestController MyClassAction:]: unrecognized selector sent to instance 0x600000029ea0

I use this function as the action:

 func MyClassAction(sender: AnyObject) -> Void {

debugPrint(sender)

}

I created a test project and pushed it on github: https://github.com/ftiff/SampleCocoaBinding/tree/master/SampleCocoaBinding

Could someone have a look? Either it's a bug or I didn't understand something key.

网友答案:

The default signature of an IBAction in Swift 3 is

func MyClassAction(_ sender: AnyObject)
相关阅读:
Top