With first macOS Catalina version, I have implemented NSSharingServicePickerToolbarItem but after macOS 10.15.1 update this don't work anymore.
I have implemented MasterViewController as activityItemConfiguration conforming UIActivityItemsConfigurationReading protocol.
Error trace
2020-06-19 10:38:29.655949+0200 WhatsHappen[11969:112649] [General] -[WhatsHappen.MasterViewController _uinsApplicationActivityProxies]: unrecognized selector sent to instance 0x100e1ab00
2020-06-19 10:38:29.656468+0200 WhatsHappen[11969:112649] [General] (
0 CoreFoundation 0x00007fff3744abe7 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff702225bf objc_exception_throw + 48
2 CoreFoundation 0x00007fff374c9c77 -[NSObject(NSObject) __retain_OA] + 0
3 UIKitCore 0x00007fff788e0c80 -[UIResponder doesNotRecognizeSelector:] + 310
4 CoreFoundation 0x00007fff373af44b _forwarding_ + 1427
5 CoreFoundation 0x00007fff373aee28 _CF_forwarding_prep_0 + 120
6 UIKitMacHelper 0x00007fff6866bb5e UINSConfigureSharingToolbarItemWithActivityItemsConfiguration + 286
7 UIKitCore 0x00007fff7884b9ef -[NSSharingServicePickerToolbarItem(UIActivityItemsConfiguration) setActivityItemsConfiguration:] + 56
Implementation
Share item configuration
let shareItem = NSSharingServicePickerToolbarItem(itemIdentifier: .share)
guard let splitViewController = rootViewController else { return nil }
guard let navigationController = splitViewController.viewControllers.first as? UINavigationController else { return nil }
guard let masterViewController = navigationController.topViewController as? MasterViewController else { return nil }
shareItem.activityItemsConfiguration = masterViewController
return shareItem
2. Protocol conforming
extension MasterViewController: UIActivityItemsConfigurationReading {
var itemProvidersForActivityItemsConfiguration: [NSItemProvider] {
if let selected = tableView.indexPathForSelectedRow, let articles = fetchedResultsController.fetchedObjects {
return [articles[selected.row].itemProvider]
}
return []
}
}
3. Item provider
var itemProvider: NSItemProvider { NSItemProvider(object: link as NSURL? ?? NSURL()) }