Open iby opened 8 years ago
It's possible there is a problem with incremental rebuilds here—there are some known issues with private methods and properties that I really want to get to in Swift 3. Is this a project you can attach—if not here, then in Radar?
Thats what I thought might be happening. Created a small project for this, the issue is reproducible 100%.
https://github.com/ianbytchek/SR-1932
Run, click buttons, the result is true
. Terminate, run again, click buttons, the result is false
. Clean build, repeat – true
. Re-run – false
.
Workaround is to manually assign correct button target. Inside view controller:
Hey @belkadan, this is really getting on my nerves. I heavily rely on interface builder and this happens in all places where I instantiate affected view controllers more than once. Is this a problem with Swift or the framework? Will reporting this on radar help at all or is this under control already? Wanna make sure whoever needs to know about this are informed.
Also made an interesting observation, perhaps related? I have following code inside a similar handler as described above.
Checked this again with the test project and everything seems to be working. @belkadan time to close this one!
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: f4c7cefc485f9bfba57b7871a3c9b3f0Issue Description:
I have a view controller in my storyboard and instantiate it with
@IBAction private func handleButtonAction(sender:NSButton)
. Often, in >80% cases, when I create my view controller usingstoryboard.instantiateControllerWithIdentifier(…)
, action handlerhandleButtonAction
gets invoked on the wrong instance of my view controller when the button gets clicked. This is what code inside the handler produces: