这就是我所拥有的:
甲类:
#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]];
}
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]];
}
这是问题所在:
在稍后的某个阶段,在 中ppApplication,我试图访问core.
core有没有。
但是,当我试图访问任何core' 元素(例如[core someObject])时,一切都变成了 NULL (我已经在调试器中检查了它)......
我究竟做错了什么??