Why UIButton selector is random crash instead of crash directly?
up vote
0
down vote
favorite
I know I should implement the Selector like arbitraryAction()
instead of arbitraryAction(_ complition: (() -> Void)?)
.Just look the code below.If you tap the Button.The code would crash random.It makes me crazy. I just want to know why the crash is random!
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let button = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100))
button.backgroundColor = .red
button.addTarget(self, action: #selector(self.arbitraryAction(_:)), for: .touchUpInside)
view.addSubview(button)
}
@objc func arbitraryAction(_ complition: (() -> Void)?) {
}
}
uibutton selector
add a comment |
up vote
0
down vote
favorite
I know I should implement the Selector like arbitraryAction()
instead of arbitraryAction(_ complition: (() -> Void)?)
.Just look the code below.If you tap the Button.The code would crash random.It makes me crazy. I just want to know why the crash is random!
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let button = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100))
button.backgroundColor = .red
button.addTarget(self, action: #selector(self.arbitraryAction(_:)), for: .touchUpInside)
view.addSubview(button)
}
@objc func arbitraryAction(_ complition: (() -> Void)?) {
}
}
uibutton selector
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I know I should implement the Selector like arbitraryAction()
instead of arbitraryAction(_ complition: (() -> Void)?)
.Just look the code below.If you tap the Button.The code would crash random.It makes me crazy. I just want to know why the crash is random!
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let button = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100))
button.backgroundColor = .red
button.addTarget(self, action: #selector(self.arbitraryAction(_:)), for: .touchUpInside)
view.addSubview(button)
}
@objc func arbitraryAction(_ complition: (() -> Void)?) {
}
}
uibutton selector
I know I should implement the Selector like arbitraryAction()
instead of arbitraryAction(_ complition: (() -> Void)?)
.Just look the code below.If you tap the Button.The code would crash random.It makes me crazy. I just want to know why the crash is random!
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let button = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100))
button.backgroundColor = .red
button.addTarget(self, action: #selector(self.arbitraryAction(_:)), for: .touchUpInside)
view.addSubview(button)
}
@objc func arbitraryAction(_ complition: (() -> Void)?) {
}
}
uibutton selector
uibutton selector
asked 2 days ago
Jules
15316
15316
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373527%2fwhy-uibutton-selector-is-random-crash-instead-of-crash-directly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown