メインの ViewController には、次のコードがあります。
- (IBAction)listFunctions:(id)sender //button clicked
{
FunctionListController *functionListController = [[FunctionListController alloc] initWithWindowNibName:@"FunctionList"];
NSWindow *functionListWindow = [functionListController window];
[NSApp runModalForWindow: functionListWindow];
NSLog(@"done");
}
FunctionListControllerの File's Owner であり、 protocolFunctionList.nibのサブクラスであり、実装しています。NSWindowControllerNSWindowDelegate
の実装は次のFunctionListControllerとおりです。
@implementation FunctionListController
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if(self)
{
// Initialization code here.
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
self.window.delegate = self;
}
- (void)windowWillClose:(NSNotification *)notification
{
[NSApp stopModal];
}
@end
モーダル ウィンドウを閉じるとNSLog(@"done");実行されて表示されますが、終了後listFunctionsに EXC_BAD_ACCESS エラーが発生します。
NSZombiesEnabledエラーが発生します[NSWindow _restoreLevelAfterRunningModal]: message sent to deallocated instance。
編集:
ARCを使用しています。