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 
1
  • -(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. Commented Apr 29, 2011 at 9:56

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

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/

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.