{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2280","labels_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2280/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2280/comments","events_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2280/events","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2280","id":102684600,"number":2280,"title":"[Question] (swift2) - NSButton and Action","user":{"login":"mobilinked","id":10665201,"avatar_url":"https://avatars.githubusercontent.com/u/10665201?v=3","gravatar_id":"","url":"https://api.github.com/users/mobilinked","html_url":"https://github.com/mobilinked","followers_url":"https://api.github.com/users/mobilinked/followers","following_url":"https://api.github.com/users/mobilinked/following{/other_user}","gists_url":"https://api.github.com/users/mobilinked/gists{/gist_id}","starred_url":"https://api.github.com/users/mobilinked/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mobilinked/subscriptions","organizations_url":"https://api.github.com/users/mobilinked/orgs","repos_url":"https://api.github.com/users/mobilinked/repos","events_url":"https://api.github.com/users/mobilinked/events{/privacy}","received_events_url":"https://api.github.com/users/mobilinked/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-24T01:53:04Z","updated_at":"2015-08-24T02:05:50Z","closed_at":null,"body":"There is no problem if I use RAC_Command to link with NSButton click event. I'd like to try link \"Action\" and NSButton via CocoaAction, but it does not work\r\n\r\n(it's NSButton for OSX, not UIButton for iOS) \r\n----------------------------- \r\n```\r\nclass ViewModel {\r\n    lazy var startAction: Action<String, Void, NoError> = {\r\n        return Action { _ in\r\n            print(\"clicked\") \r\n            return SignalProducer<Void, NoError>.empty\r\n        }\r\n    }()\r\n}\r\n\r\nprivate var button: NSButton! \r\nlet viewModel = ViewModel() \r\nsetupBind() {\r\n    self.button.target = CocoaAction(viewModel.startAction, input: \"\")\r\n    self.button.action = CocoaAction.selector\r\n}\r\n```\r\n------------- \r\nThe problem is that after button be clicked, action is not fired. \r\n"},"comment":{"url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/comments/133990777","html_url":"https://github.com/ReactiveCocoa/ReactiveCocoa/issues/2280#issuecomment-133990777","issue_url":"https://api.github.com/repos/ReactiveCocoa/ReactiveCocoa/issues/2280","id":133990777,"user":{"login":"ikesyo","id":909674,"avatar_url":"https://avatars.githubusercontent.com/u/909674?v=3","gravatar_id":"","url":"https://api.github.com/users/ikesyo","html_url":"https://github.com/ikesyo","followers_url":"https://api.github.com/users/ikesyo/followers","following_url":"https://api.github.com/users/ikesyo/following{/other_user}","gists_url":"https://api.github.com/users/ikesyo/gists{/gist_id}","starred_url":"https://api.github.com/users/ikesyo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikesyo/subscriptions","organizations_url":"https://api.github.com/users/ikesyo/orgs","repos_url":"https://api.github.com/users/ikesyo/repos","events_url":"https://api.github.com/users/ikesyo/events{/privacy}","received_events_url":"https://api.github.com/users/ikesyo/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T02:05:50Z","updated_at":"2015-08-24T02:05:50Z","body":"I think this is because the created `CocoaAction(viewModel.startAction, input: \"\")` are not strongly referenced anywhere (`NSControl.target` is an weak property), so the action is deallocated immediately. You should hold the action somewhere, for example in your view model or set the action to `Action.unsafeCocoaAction` property."}}