Class A :
#import "ppCore.h"
@interface ppApplication : NSApplication {
ppCore* core;
}
@property (assign) ppCore* core;
@end
@implementation ppApplication
@synthesize core;
- (void)awakeFromNib
{
[self setCore:[[[ppCore alloc] init] retain]];
}
Class B :
#import "someObject.h"
#import "anotherObject.h"
@interface ppCore : NSObject<NSApplicationDelegate> {
ppSomeObject* someObject;
ppAnotherObject* anotherObject;
}
@property (assign) ppSomeObject* someObject;
@property (assign) ppAnotherObject* anotherObject;
@end
@implementation ppCore
@synthesize someObject, anotherObject;
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
[self setSomeObject:[[ppSomeObject alloc] init]];
[self setAnotherObject:[[ppAnotherObject alloc] init]];
}
AT SOME LATER STAGE, in ppApplication
, I'm trying to have access to core
.
core
is there.
But, when I'm trying to access any of core
's elements (e.g. [core someObject]
), everything is turning up NULL (I've checked it in the Debugger)...
What am I doing wrong??
I suggest you remove the whole core
thing since you can access your delegate through [[NSApplication sharedApplication] delegate]
and move the setting of someObject and anotherObject to the delegate's init method.