iPhone, how do usa an App Delegate variable so it can be used like global variables?
问题 Heres the code I'm using, see my error afterwards @interface MyAppDelegate : NSObject { NSString *userName; } @property (nonatomic, retain) NSString *userName; ... @end and in the .M file for the App Delegate you would write: @implementation MyAppDelegate @synthesize userName; ... @end Then, whenever you want to fetch or write userName, you would write: MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; someClass.someString = appDelegate.userName; //..to fetch