Friday, August 27, 2010

How to call a method AKA IBACTION in an XCODE project.

To call a Method or IBACTION in an XCODE project you have to use the following command.




[self methodname];




for example lets say you have the following methods AKA IBACTIONS in your .h file of you xcode project.




-(IBAction)method1;
-(IBAction)method2;

-(IBAction)method3;

-(IBAction)method4;





And you have all of them defined as following in your .M File of your XCODE project.


-(IBAction)method1

{

//do something

}







-(IBAction)method2


{


//do something


}









-(IBAction)method3


{


//do something


}









-(IBAction)method4


{


//do something


}
















Now for example if you want to call method2 from method1 you will do the following:







-(IBAction)method1


{


[self method2];






}






This is a fundamental concept in XCODE to understand.




This code has been test in XCODE 3.2.3 and IPHONE SDK 4.00.
If anyone has a better way of doing this please send an e-mail to timbojill@gmail.com. I do not read comments left behind by users.

No comments:

Post a Comment