I have 3 buttons which call the same function. I want to know inside the function which button called it. Is it possible to know it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can use the
senderargument. If you have an IBOutlet calledbuttonOne, you can check inside the IBAction method like this:Alternatively, assign each of your buttons a
tag, and use the sender’stagproperty (the following example assumes thatbuttonOnewas assigned the tag value “1”):