2

In the following code what is the function of -(IBAction)setLabelPushed:(id)sender;

#import <UIKit/UIKit.h> 
@interface BasicIPhoneAppViewController : UIViewController 
{ 
    IBOutlet UILabel *myLabel; 
    IBOutlet UITextField *myTextField; 
} 
-(IBAction)setLabelPushed:(id)sender;
@end 
Anatolij
  • 597
  • 3
  • 11
Junior Bill gates
  • 1,858
  • 4
  • 20
  • 33
  • `-(IBAction)setLabelPushed:(id)sender` you will be needing this method when you connect your Control to a certain Event, the interface builder will allow you to connect the control with events only with defined method as `IBAction` if your not planing to use it in interface builder then keep it void, or whatever returning type you need. – Ahmad Kayyali Apr 29 '11 at 09:56

4 Answers4

1

Actually it is a non-static method. IBAction means that it can be used as a event handler in Interface Builder (it can be linked to some action). You should provide more details, for example the body of setLabelPushed function.

0

get the value from textfield and show it in the label .I think so......

Aman Aggarwal
  • 3,754
  • 1
  • 19
  • 26
0

It is a method you can bind from within the Interface Builder...

http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-interface-builder-basic-training/

lithium
  • 995
  • 7
  • 13
0

IBAction resolves to "void" and IBOutlet resolves to nothing, but they signify to Xcode and Interface builder that these variables and methods can be used in Interface builder to link UI elements to your code.

If you're not going to be used Interface Builder at all, then you don't need them in your code, but if you are going to use it, then you need to specify IBAction for methods that will be used in IB and IBOutlet for objects that will be used in IB. IBOutlet and IBAction

Community
  • 1
  • 1
Ahmad Kayyali
  • 8,233
  • 13
  • 49
  • 83