Reputation: 1331
I have a function
@IBAction func fblogin(sender: AnyObject) {
println (sender)
}
The action of two button is this function. If I print sender nil gets printer. How do I check which button called it. Do I need to create outlet for buttons or how do I create ids for buttons?
Upvotes: 3
Views: 5017
Reputation: 14904
You could use sender
's tag
value
Just connect both buttons to your action, and check with:
if(sender.tag == 1) {
... button 1
} else if( sender.tag == 2) {
.. button 2
}
And use sender from type UIButton (you can select it directly in Xcode too)
tag
value?
Upvotes: 2