AppController.h
#import <Cocoa/Cocoa.h>
#import "DebugController.h"
@class DebugController;
@interface AppControlle开发者_如何转开发r : NSObject {
DebugController * controller;
}
@end
AppController.m
#import "AppController.h"
@implementation AppController
-(void)awakeFromNib {
NSLog(@"awake");
[controller sendDebug];
}
@end
DebugController.h
#import <Cocoa/Cocoa.h>
#import "AppController.h"
@interface DebugController : NSObject {
}
- (void)sendDebug;
@end
DebugController.m
#import "DebugController.h"
@implementation DebugController
- (void)sendDebug {
NSLog(@"debug"); // no logs.
}
@end
You don't initialize the debug controller (controller
), which means its initially nil
(as its an instance variable). Sending a message to nil
is legal, but nothing happens. You have to initialize your debug controller ivar first.
精彩评论