koz
koz

Reputation: 305

How can I tell which button was pressed LAST - SWIFT?

Pretty basic - I have multiple buttons and I just need to tell which button was pressed most recently, despite how many times on each or how long between clicks.

Upvotes: 2

Views: 508

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726499

  • Give each button a unique tag in Interface Builder.
  • Make a variable that holds the tag of the last button that has been clicked.
  • In event handlers of your buttons set the variable from the step above to the tag of the button currently being clicked.
  • When you need to find the last button that has been clicked, check the variable, it will have the unique tag of your button.

Upvotes: 1

Related Questions