changeView_ShowContact 메소드를 사용하면보기 컨트롤러가 올바르게 표시됩니다. 하지만 다른 클래스에서 changeView_ShowContact를 호출하면 작동하지 않을 것입니다. 로그에 "인스턴스로 보낸 인식 할 수없는 선택기"오류가 발생했습니다.objective C OSX - 대리인 - 인스턴스로 전송 된 알 수없는 선택자
@protocol callingActions_fromMainNavigation <NSObject>
- (IBAction)changeView_ShowContact:(id)sender;
@end
**@interface Navigation_Main : NSViewController**
@property (nonatomic, strong) id <callingActions_fromMainNavigation> delegate;
**@implementation Navigation_Main**
@synthesize delegate;
- (IBAction)changeView_ShowContact:(id)sender;
{
NSLog(@"********************ShowContact");
AddStuffViewController = [[pageContact alloc] initWithNibName:@"pageContact" bundle:nil];
[AddStuffView addSubview:[AddStuffViewController view]]; //<This call here works ok.
}
.
@interface contacts : NSObject <callingActions_fromMainNavigation>
**@implementation contacts**
-(void)myMethodCall:(id)sender;
{
Navigation_Main *NavMain = [[Navigation_Main alloc] initWithNibName:@"Navigation_Main.h" bundle:nil];
[NavMain setDelegate:self];
[self changeView_ShowContact:nil];
//I need to call the (IBAction)changeView_ShowContact in the Main Navigation. This
//code is not working.
}
밑줄은 클래스 이름에 거의 사용되지 않으며'contacts' 클래스는 대문자이어야하며 이상적으로 3 자의 고유 한 접두어가 있어야합니다. – CodaFi