Forked from sindresorhus/NSSharingService-sharingServices-deprecation-warning-fix.swift
Created
September 7, 2024 18:46
-
-
Save jaywcjlove/42901eda337ae046ec53bfd190606f2f 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 hidden or 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