我使用此代碼以模態視圖顯示窗口控制器窗口。我在窗口中的按鈕窗口控制器中執行操作。當我點擊按鈕時,應用程序崩潰,並得到沒有錯誤信息。我在設置代表時錯了嗎?窗口控制器委託錯誤
[[NSApplication sharedApplication] beginSheet:windowObj.window modalForWindow:self.view.window modalDelegate:windowObj didEndSelector:nil contextInfo:nil];
我使用此代碼以模態視圖顯示窗口控制器窗口。我在窗口中的按鈕窗口控制器中執行操作。當我點擊按鈕時,應用程序崩潰,並得到沒有錯誤信息。我在設置代表時錯了嗎?窗口控制器委託錯誤
[[NSApplication sharedApplication] beginSheet:windowObj.window modalForWindow:self.view.window modalDelegate:windowObj didEndSelector:nil contextInfo:nil];
windowObj
被解除分配(可能由ARC如果正在使用的話)之前,片材可以顯示該窗口。你應該添加一個強大的屬性到你正在使用的任何類中,並將windowObj設置爲如下所示:
@property (strong) MyWindowController *windowObj;
...
// Instantiate the window controller
self.windowObj = [[windowController alloc] initWithWindowNibName:@"windowController"];
[[NSApplication sharedApplication] beginSheet:windowObj.window modalForWindow:self.view.window modalDelegate:windowObj didEndSelector:nil contextInfo:nil];
添加異常斷點並重試。我們需要一個堆棧跟蹤以幫助... – trojanfoe
我試過了。我沒有得到任何異常,它停止在'返回NSApplicationMain(argc,(const char **)argv);'與EXC_BAD_ACCESS一致(代碼= EXC_1386_GPFLT) – prabhu
您應該能夠捕獲該異常的根本原因...... – trojanfoe