How do I use a switch statement to find if a UIButton is pressed?

I'm a little rusty on iOS development but you could probably do the following: Set the buttons to the same event handler and use the sender attribute to get to the tag element of the button which you can specify to each button (IBAction) doStuff:(id) sender { UIButton *button = (UIButton*) sender; switch(button. Tag) { //do stuff } If this doesn't work out for you, you can use any of the button properties you see fit to differentiate between them such as title, title color and so on For best practices i'd advise you to also check if the sender is of type UIButton before trying to cast it into an object.

I'm a little rusty on iOS development but you could probably do the following: Set the buttons to the same event handler and use the sender attribute to get to the tag element of the button which you can specify to each button. - (IBAction) doStuff:(id) sender { UIButton *button = (UIButton*) sender; switch(button. Tag) { //do stuff } If this doesn't work out for you, you can use any of the button properties you see fit to differentiate between them such as title, title color and so on.

For best practices i'd advise you to also check if the sender is of type UIButton before trying to cast it into an object.

1 You're not rusty, it's exactly the way I'd do it, with tags. I'd also typedef an enum with all possible tags, that's more flexible. – Cyrille Nov 18 at 20:46.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions