2012-02-21 64 views
1

我加载纸张到我的主要的.xib,薄片是面板和我没有问题,显示板或关闭,但是当我关闭它我得到一个错误信息:可可beginSheet:didEndSelector抛出一个错误

2012-02-21 11:10:12.142 CollectionTest2[23277:10b] *** - 
[AppController customSheetDidClose:returnCode:contextInfo:]: unrecognized selector sent to instance 0x359c00 

这里是我的代码:

/*Sheet Methods*/ 

- (void)showCustomSheet: (NSWindow *)window { 

    [NSApp beginSheet: panFilenameEditor modalForWindow: window modalDelegate: self didEndSelector: @selector(customSheetDidClose:returnCode:contextInfo:) contextInfo: nil]; 
} 

- (IBAction)closeCustomSheet:(id)sender { 

    [panFilenameEditor orderOut:self]; 
    [NSApp endSheet:panFilenameEditor]; 
} 

- (void) customSheetDidClose { 

    NSLog(@"sheet did close"); 
} 

回答

1

在你showCustomSheet方法,你告诉纸张调用选择customSheetDidClose:returnCode:contextInfo:您的应用程序控制器。但是没有这样的方法。

解决办法有两个:

  • 要么通过@selector(customSheetDidClose)在您的来电beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
  • 或重命名你customSheetDidCloseMethod- (void)customSheetDidClose:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+0

@DD - 谢谢,我只是在看文档再次不理解,但你的解释是有道理的。应用程序现在工作正常。 – PruitIgoe 2012-02-21 17:14:29