Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sindresorhus/b9c40ac15ce77616a306249303c05a10 to your computer and use it in GitHub Desktop.
Save sindresorhus/b9c40ac15ce77616a306249303c05a10 to your computer and use it in GitHub Desktop.
macOS 13 deprecated `NSSharingService.sharingServices()`. Here's how to silence the deprecation until you can move to the new API.
private protocol SilenceDeprecationNSSharingService {
func sharingServices(forItems items: [Any]) -> [NSSharingService]
}
private final class SilenceDeprecationNSSharingServiceImplementation: SilenceDeprecationNSSharingService {
@available(macOS, deprecated: 13)
func sharingServices(forItems items: [Any]) -> [NSSharingService] {
NSSharingService.sharingServices(forItems: items)
}
}
extension NSSharingService {
static func sharingServices2(forItems items: [Any]) -> [NSSharingService] {
(SilenceDeprecationNSSharingServiceImplementation() as SilenceDeprecationNSSharingService).sharingServices(forItems: items)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment