我希望视图控制器能够dog
在应用程序委托中访问。
我希望应用程序委托能够mouse
在视图控制器中访问。
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
int mouse; // <----------------
}
@end
- (void)viewDidLoad
{
[super viewDidLoad];
mouse = 12; // <-------------------
NSLog(@"viewDidLoad %d", dog); // <---------------
}
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
int dog; // <---------------
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"applicationWillResignActive %d", mouse); // <--------------
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
dog = 77; // <---------------------
NSLog(@"applicationDidBecomeActive");
}