Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sindresorhus/e304f157e1fc2b4e63dedc151b25b583 to your computer and use it in GitHub Desktop.
Save sindresorhus/e304f157e1fc2b4e63dedc151b25b583 to your computer and use it in GitHub Desktop.
iOS 16 deprecated `UIScreen#screens`. Here's how to silence the deprecation until you can move to the new API.
private protocol SilenceDeprecationForUIScreenWindows {
var screens: [UIScreen] { get }
}
private final class SilenceDeprecationForUIScreenWindowsImplementation: SilenceDeprecationForUIScreenWindows {
@available(iOS, deprecated: 16)
var screens: [UIScreen] { UIScreen.screens }
}
extension UIScreen {
static var screens2: [UIScreen] {
(SilenceDeprecationForUIScreenWindowsImplementation() as SilenceDeprecationForUIScreenWindows).screens
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment