Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Laura Paxton
2,304 PointsI want one button to three actions, all of which will happen at once (or in quick successive order). How do I do this?
I don't remember this being covered in any of the tutorials. This is in Swift. I have a button that makes random info appear in a label. I also want it to generate an image and to make different random info appear in a different label. I might figure this out before I hear back from anyone.. but I've been working on this a long time.. Does anyone know how off the top of their head? Thanks.
3 Answers
Iago Wandalsen Prates
21,699 PointsBasically, when the function is called, you want it do to multiple actions.
So what you are going to do is do multiple actions inside the trigger, like
@IBAction func whatever{
action1()
action2()
action3()
}
And then have the 3 functions you want to happen elsewhere.
Laura Paxton
2,304 PointsThanks, Iago. I am still confused but what I'm trying to do is complicated. This helps though.
Laura Paxton
2,304 PointsThanks. I have this working now, although my code is overcomplicated, most likely. I keep dragging each new action from the button, one at a time. For some reason, doing what you suggested was confusing within the overall context of the task I was working on.