I would like to use my AppDelegate to store a object which will be accessible to any other classes. I've declared this AppDelegate like this :
@interface MyAppDelegate : UIResponder <UIApplicationDelegate>
{
MyClass *tracker;
}
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ICViewController *viewController;
@property (retain, nonatomic) MyClass *tracker;
@end
I synthesize tracker and in application:didFinishLaunchingWithOptions: i set one NSString in that object like this :
self.tracker = [[MyClass alloc] init];
self.tracker.testGlobal = @"global funguje";
When i need to access tracker somewhere else in some other class i use this code :
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
MyClass *trackerTEST = appDelegate.tracker;
NSLog(@"TEST : %@",trackerTEST.testGlobal);
The problem is that testGlobal is NULL. What am I doing wrong? Also here are class files for MyClass :
@interface MyClass : NSObject
{
NSString *testGlobal;
}
@property (retain, nonatomic) NSString *testGlobal;
@end
@implementation MyClass
@synthesize testGlobal = _testGlobal;
@end
Thanks for any kind of help!