Errors

Modal session requires modal window

@implementationMainWindowController{PreferencesWindowController*_preferencesWC;// This is simply a NSWindowController
}-(void)awakeFromNib{[superawakeFromNib];_preferencesWC=[[PreferencesWindowControlleralloc]initWithWindowNibName:@"PreferencesWindow"];}-(IBAction)menuShowPreferences:(id)sender{if([self.windowattachedSheet]==nil){[NSAppbeginSheet:_preferencesWC.windowmodalForWindow:self.windowmodalDelegate:selfdidEndSelector:@selector(didEndSheet:returnCode:contextInfo:)contextInfo:nil];}else{[NSAppendSheet:_preferencesWC.window];}}-(void)didEndSheet:(NSWindow*)sheetreturnCode:(NSInteger)returnCodecontextInfo:(void*)contextInfo{[sheetorderOut:self];}