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!
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

Robert Vazquez
1,782 Pointswhat is the difference between IBOutlet and IBActions in Xcode with Swift
I am starting out to use Xcode with Swift but I am suck when they are talking about using IBOutlet and IBActions in Xcode BUT I don't understand the difference between the two. please help
2 Answers

Richard Lu
20,185 PointsHey Robert,
IBOutlets are used for referencing something that's on the storyboard. Let's say there's a button on the storyboard that needs to be access in the code, you can control drag it onto the associated viewcontroller class file.
@IBOutlet weak var aButton: UIButton!
the button can now be manipulated in that class file
aButton.currentTitle = "I've change the buttons title"
IBActions are used for "actions", what happens when i click on this button?
@IBAction func buttonPressed(sender: AnyObject) {
print("HEY! I'VE PRESSED THE BUTTON")
}
Hope I've helped. Happy Coding! :)

Robert Vazquez
1,782 Pointsyes Thanks for helping me out with this in Xcode Thanks a lot Richard

Richard Lu
20,185 PointsAnytime Robert, I'm always looking to help! :)