2011-04-06 1 views
0

AppController.h다른 컨트롤러에서 함수 호출, 왜 작동하지 않습니까?

#import <Cocoa/Cocoa.h> 
#import "DebugController.h" 

@class DebugController; 
@interface AppController : 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 

답변

3

당신은 디버그 C를 초기화하지 않습니다 ontroller (controller)는 처음에 nil (인스턴스 변수로)을 의미합니다. nil으로 메시지를 보내는 것은 정상이지만 아무 일도 일어나지 않습니다. 먼저 디버그 컨트롤러 ivar를 초기화해야합니다.