Running Code on Tap
Print, count, and trigger logic from a tap.
The Action Is Yours
The closure inside a button is where your app does real work. This is where you run logic, update data, or kick off a task on tap. ⚡
Printing for a Quick Test
The simplest action is a print. It writes to Xcode's console so you can confirm a tap was registered while you build.
Button("Test") {
print("Button was tapped")
}All lessons in this course
- Creating a Tappable Button
- Styling Buttons
- Running Code on Tap
- Disabling & Enabling Buttons