使用NSSharingServicePicker类

时间:2018-05-03 10:37:50

标签: swift macos

  

2018-05-03 18:31:54.879424 + 0800作家[5656:137819]警告:非法   子类SHKRemoteView实例化;客户应该只使用   NSRemoteView(0 ViewBridge
  0x00007fff7a0cabff - [NSRemoteView _preSuperInit] + 195 1 ViewBridge   0x00007fff7a0caf83 - [NSRemoteView initWithFrame:] + 25 2 ShareKit
  0x00007fff763b7aa5 - [SHKRemoteView initWithOptionsDictionary:] + 161     3 ShareKit 0x00007fff76396fbd    38- [SHKSharingService performWithItems:] _ block_invoke_4 + 1347 4 libdispatch.dylib 0x00000001019eacfe   _dispatch_call_block_and_release + 12 5 libdispatch.dylib 0x00000001019e2ddf _dispatch_client_callout + 8 6 libdispatch.dylib   0x00000001019eee59 _dispatch_main_queue_callback_4CF + 549 7
  CoreFoundation 0x00007fff5515bc69   __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
+ 9 8 CoreFoundation 0x00007fff5511de4a __CFRunLoopRun   + 2586 9 CoreFoundation 0x00007fff5511d1a3 CFRunLoopRunSpecific + 483 10 HIToolbox
  0x00007fff54405d96 RunCurrentEventLoopInMode + 286 11 HIToolbox
  0x00007fff54405b06 ReceiveNextEventCommon + 613 12 HIToolbox
  0x00007fff54405884 _BlockUntilNextEventMatchingListInModeWithFilter +   64 13 AppKit 0x00007fff526b8a73   _DPSNextEvent + 2085 14 AppKit 0x00007fff52e4ee34 - [NSApplication(NSEvent)   _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044 15 AppKit 0x00007fff526ad885 - [NSApplication   运行] + 764 16 AppKit 0x00007fff5267ca72   NSApplicationMain + 804 17 writer111
  0x00000001002adf9d main + 13 18 libdyld.dylib
  0x00007fff7d437015 start + 1 19 ???   0x0000000000000003 0x0 + 3)

虽然效果很好,但这条警告信息让我恼火,我希望它会消失。

一种非常简单的方法,但它有这样的警告。

let sharingService = NSSharingServicePicker(items: ["111"]);
sharingService.show(relativeTo: sender.bounds, of: sender, preferredEdge: .minX);

1 个答案:

答案 0 :(得分:2)

我不知道警告的原因,但是我能够通过在新的runloop上显示选择器来使其静音:

let sharingService = NSSharingServicePicker(items: ["111"]);
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now(), execute: {
    sharingService.show(relativeTo: sender.bounds, of: sender, preferredEdge: .minX)
})