objective c - How to close window fired up from NSWindowController -
very nob question: want close window programmatically after sent http post body data. read documentation , implemented method - (void) performclose : ( id ) sender; , - ( bool ) windowshouldclose : ( id ) sender; never called. please can put me in right direction code provided below achieve mi target? thank gold time.
my code:
#import <cocoa/cocoa.h> #import <appkit/appkit.h> //.h @interface postinoclass : nswindowcontroller <nsurlsessiondatadelegate, nsurlconnectiondelegate,nsurlsessiontaskdelegate,nsurlconnectiondatadelegate> { nswindowcontroller *controllerwindow; } //.m - (void)openwindow { // nslog(@"openwindow"); controllerwindow = [[nswindowcontroller alloc]initwithwindownibname:@"sendemailwindow"]; [controllerwindow showwindow:self]; }
//ok can open cool window, need close after dirty work...
- (void)closewindow:(id)sender { // nslog(@"closewindow"); // [controllerwindow close]; // not work <-- [controllerwindow.window performclose:sender]; //not work <-- }
[[self window] close];
that's it.
documentation link.
Comments
Post a Comment