Pages

Wednesday, June 4, 2014

How to call a method IN AppDelegate in iOS ?

Step 1 : Declare the method in AppDelegate.h file .  (example:-   -(void)methodName ; )

Step 2 : Import AppDelegate.h in your desired class file .  (example :- #import "AppDelegate.h" ; )

Step 3 : Create an instance of AppDelegate in desired class file .
           
           Example:

             -(void)sampleMethod
          {
             AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];

             [appDelegate methodName];
          }

No comments:

Post a Comment