I have a global variable defined in Appdelegate.I want to use in other controller.
And I can use like this :
AppDelegate *appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
appdelegate.name=[NSString stringwithFormat:@"%@",ename];
But whereever I want to access appdelegates variable in viewController I have to use AppDelegate *appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate]; each time which gives warning messages like ‘Local declaration of AppDelgate hides instance variables ‘.So is there a way that I could declare it only once any access it many times in a ViewController.How can I get rid of this warning?
EDIT:
.h :
#import "AppDelegate.h"
@interface More : UIViewController
{
AppDelegate *appdelegate;
}
.m:
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate]; //error :Use of undeclared identifier appDelegate
}
if your problem is just the warning, change the local name of the pointer to your appDelegate: