这不是一个非常重要的问题,但我很好奇它为什么会发生。基本上,我使用以下代码打开NSSharingService
窗口:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Get the sharable items from a custom method
NSArray *shareItems = self.sharableItems;
// Pick service dependent on type sent via JS
NSSharingService *service;
if ([shareType isEqualToString:@"Messages"]){
service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeMessage];
} else if ([shareType isEqualToString:@"Email"]){
service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
} else if ([shareType isEqualToString:@"Facebook"]){
service = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnFacebook];
} else if ([shareType isEqualToString:@"Twitter"]){
service = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnTwitter];
}
service.delegate = self;
// Update the UI in the main thread
dispatch_async(dispatch_get_main_queue(), ^{
[service performWithItems:shareItems];
});
});
NSSharingService
窗口正常打开,但当我发送"发送"或者"取消"发送消息,控制台输出:
_NXTermWindow:错误释放窗口(1001)
Google produced no helpful results。值得注意的是,我实施了以下相关方法:
- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope{
return self.window;
}
- (void)sharingService:(NSSharingService *)sharingService didShareItems:(NSArray *)items;
- (void)sharingService:(NSSharingService *)sharingService didFailToShareItems:(NSArray *)items error:(NSError *)error;