Created
October 19, 2022 07:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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