内にあるNSStringfromにアクセスしたい。AppDelegate.mViewController.m
私はSingle View Applicationを持っNSStringています。applicationDidEnterBackground:AppDelegate.m
はNSString内ViewController.mにあり、 では宣言されていませんAppDelegate.m。
私はそれを宣言してからAppDelegate.hアクセスしようとしましたViewController.m(そして逆に)。
ViewController.h:
@interface MyAppViewController : UIViewController {
NSString *MyString;
}
AppDelegate.m:
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:MyString forKey:@"SavedString"];
[defaults synchronize];
}