In your view, the controller header file adds the mouse as a property:
Synthesize a property in an implementation of your view controller just below the @implementation line:
@synthesize mouse;
In its case, the application delegate adds the dog as a property:
@interface AppDelegate : UIResponder <UIApplicationDelegate> { NSInteger dog; // <--------------- } @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) ViewController *viewController; @property (nonatomic, assign) NSInteger dog; @end
Also synthesize a dog in its application delegation implementation.
Now in application deletion, assuming that you have a link to a controller of your kind, you can access the mouse as follows:
viewController.mouse = 13;
You can do the same with the application delegation class, which can be accessed from any view controller using (assuming the AppDelegate application delegate class name):
((AppDelegate *)([UIApplication sharedApplication].delegate)).dog = 13;
I would recommend you also use NSInteger instead of int.
source share