I am new to Xcode and I am wondering, what does IBAction and IBOutlet do? I've tried doing simple task like 'hello world' but it seems I stuff it up. I am making app that involves a questionnaire that links to a database.
-
possible duplicate of [IBOutlet and IBAction](http://stackoverflow.com/questions/1643007/iboutlet-and-ibaction) – JPetric Aug 12 '13 at 06:25
-
You can use IBAction if you want to give some action to happen when you press the button or any controller and you can use IBOutlet if you want to set properties fro that label or button. – Manthan Aug 12 '13 at 06:27
2 Answers
IBAction is used for Methods which performs as a result of any Action for example Button Press.
-(IBAction) buttonPress : (id) sender;
IBOutlet is used for UI related objects like Button,label, View etc.
IBOutlet UILabel *nameLabel;
Note: If you are using XIB for development, you should make use of IBAction and IBOutlet. Otherwise you will not able to map objects and methods on XIB. If you are developing everything by coding then IBAction and IBOutlet are optional.

- 635
- 5
- 17
-
so if i want a button when pressed, it goes to another controller will this be the correct code under main controller .h - (IBAction) Enter; – Arthur Aug 18 '13 at 04:50
As mentioned in the answer linked above: "IBAction and IBOutlet are macros defined to denote variables and methods that can be referred to in Interface Builder."
However in layman's terms and a simple way to think of them -
IBActions mark the methods that will be called when an event (e.g. touch down) is triggered on one of your interface builder controls (e.g. button, switch etc).
IBOutlets mark the variable references for your interface builder controls. Outlets allow you to programatically interact with controls you layout on interface builder.

- 22,184
- 15
- 80
- 118