Sometimes u would need to create some Global Variables in an iPhone Application such that they can be accessed in other implementation class files.
Those Global Variables are created in the AppDelegate. If you want to access it in another file, you have to get the AppDelegate instance before you can read or write the Global Variables. For example, the HelloAppDelegate has a NSString instance variable named as greeting and i want to read it in the HelloViewController.m
// Get the HelloAppDelegate HelloAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; // Show the greeting in the log NSLog(appDelegate.greeting);
An alternate way is creating and wiring an app delegate variable in the HelloViewController with the App Delegate Object in the MainWindow.xib.
Thanks Steve for telling me about that.