Interface:
@interface MyAppDelegate : NSObject {
NSString *myString;
}
@property (nonatomic, retain) NSString *myString;
...
@end
and in the .m file for the App Delegate you would write:
@implementation MyAppDelegate
@synthesize myString;
myString = some string;
@end
Then, in viewcontroller.m file you can fetch:
MyAppDelegate *appDelegate = (MyAppDelegate*)[[UIApplication sharedApplication] delegate];
someString = appDelegate.myString; //..to read
appDelegate.myString = some NSString; //..to write
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…