Can't connect button in Your First Mac App with Fire


(Jon Cook) #1

Hi,
I’m trying FIre out for the first time, working through this tutorial: https://docs.elementscompiler.com/Tutorials/FirstApp/Fire/Mac/

I’m using Swift & I have connected the button in XCode as described (control drag from button to File’s Owner). When I try to run in Fire I get this message: Could not connect action, target class MainWindowController does not respond to -sayHello:

(and obviously the button does not work).

I’m using Fire: 9.0.97.2071 and XCode 8.3.2


(marc hoffman) #2

can i see the project?


(Jon Cook) #3

sure:
MacAppUsingFire.zip (2.3 MB)


(marc hoffman) #4

thanx. i’ll, have a look in the morning.


(Jon Cook) #5

hi - any luck?


(marc hoffman) #6

My sincerest apologies; i lost track as i was swamped, getting the next release sorted. I’ll have a look right now.


(marc hoffman) #7

There you go:

	@IBAction func sayHello(sender: Any?) { // NW5 IBAction/objc methods should have an unlabeled prefix for the first parameter
		// label.stringValue = "hello, "+edit.stringValue
		print("Hello")
	}

(that warning might be new for the upcoming 9.1, so maybe you don’t see that yet). you need to add underscore, because otherwise your sayHello method won’t be called sayHello:, but has an external prefix for the first parameter.

@IBAction func sayHello(_ sender: Any?) { /

will work.

That said, this method should not even have made it thru to the Xcode sync as id did, i will log an issue for that.


(RemObjects) #8

Thanks, logged as bugs://77833: Swift methods with prefix should not sync prefix-less to Xcode.

This won’t make it into the upcoming release, as that’s locked down and will (hopefully) be finalized friday, but I’ve given this priory’s for the next 9.2 interim.

thanx!


(RemObjects) #9

bugs://77833 got closed with status fixed.