非常nob问题:我想在发送HTTP POST正文数据后以编程方式关闭窗口。我阅读了文档并实现了该方法 - (void)performClose:(id)sender; 和 - (BOOL)windowShouldClose:(id)sender;但从未打电话过。那么请您从下面提供的代码中找到正确的方向来实现mi目标吗? 谢谢你的黄金时间。
我的代码:
#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];
}
//好吧现在我可以打开我的酷窗口了,但需要在一些肮脏的工作后关闭......
- (void)closeWindow:(id)sender {
// NSLog(@"closeWindow");
// [controllerWindow close]; // not work <--
[controllerWindow.window performClose:sender]; //not work too <--
}