{"action":"closed","issue":{"url":"https://api.github.com/repos/IntrepidPursuits/swift-style-guide/issues/41","repository_url":"https://api.github.com/repos/IntrepidPursuits/swift-style-guide","labels_url":"https://api.github.com/repos/IntrepidPursuits/swift-style-guide/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/IntrepidPursuits/swift-style-guide/issues/41/comments","events_url":"https://api.github.com/repos/IntrepidPursuits/swift-style-guide/issues/41/events","html_url":"https://github.com/IntrepidPursuits/swift-style-guide/issues/41","id":333262483,"node_id":"MDU6SXNzdWUzMzMyNjI0ODM=","number":41,"title":"@IBAction vs button.addTarget()","user":{"login":"jpmendel","id":24812468,"node_id":"MDQ6VXNlcjI0ODEyNDY4","avatar_url":"https://avatars0.githubusercontent.com/u/24812468?v=4","gravatar_id":"","url":"https://api.github.com/users/jpmendel","html_url":"https://github.com/jpmendel","followers_url":"https://api.github.com/users/jpmendel/followers","following_url":"https://api.github.com/users/jpmendel/following{/other_user}","gists_url":"https://api.github.com/users/jpmendel/gists{/gist_id}","starred_url":"https://api.github.com/users/jpmendel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpmendel/subscriptions","organizations_url":"https://api.github.com/users/jpmendel/orgs","repos_url":"https://api.github.com/users/jpmendel/repos","events_url":"https://api.github.com/users/jpmendel/events{/privacy}","received_events_url":"https://api.github.com/users/jpmendel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-18T13:09:20Z","updated_at":"2018-06-26T17:43:43Z","closed_at":"2018-06-26T17:43:43Z","author_association":"NONE","body":"When it comes to assigning actions to views we can interact with, which method of binding that action is better to use?\r\n\r\n```\r\nXIB File -> Connect to Code\r\n```\r\nthen\r\n```\r\n@IBAction func buttonPressed(_ sender: UIButton) {\r\n    // do stuff\r\n}\r\n```\r\n\r\nOR\r\n\r\n```\r\nbutton.addTarget(self, action: #selector(buttonPressed(_:)), for: .touchUpInside)\r\n```\r\nthen\r\n```\r\n@objc func buttonPressed(_ sender: UIButton) {\r\n    // do stuff\r\n}\r\n```\r\n\r\nThe first we can only do if we use .xibs or storyboards, but if both are available, which is preferred?"}}
{"actor":{"display_login":"alexpersian"}}