Skip to content

Commit

Permalink
Added NSObject, ByDevice, and hasDynamicIsland
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcrich23 committed May 5, 2024
1 parent 4f80240 commit 8415912
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ByDevice

@Metadata {
@TitleHeading("Class")
@PageColor(blue)
}
Seems to be similar to `UIDevice`

## Overview

> Warning: It is unknown when this class was added, and to which operating systems, testing is required before production use. `ByDevice` may be removed at any time.
## Topics

- <doc:hasDynamcIsland>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# hasDynamcIsland
Detect if a device has the Dynamic Island.

@Metadata {
@TitleHeading("Instance Property")
@PageColor(green)
}

## Overview

`hasDynamicIsland` is a property of [`ByDevice`](<doc:ByDevice>) that can provide a non-hardcoded boolean value of whether or not a device has the Dynamic Island

> Warning: It is unknown when this property of `ByDevice` was added, and to which operating systems, testing is required before production use. `ByDevice` and/or `hasDynamicIsland` may be removed at any time.
## Method

We can use this code to get the future-proof boolean:
```swift
let BYDeviceClass = NSClassFromString( "BYDevice") as! NSObject.Type
let bydevice = BYDeviceClass.perform(NSSelectorFromString("currentDevice")).takeUnretainedValue() as! NSObject
let hasDynamicIsland = bydevice.value(forKey: "hasDynamicIsland") as! Bool

print(hasDynamicIsland)
```
4 changes: 4 additions & 0 deletions Sources/NotPrivateApis/NotPrivateApis.docc/NotPrivateApis.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ NotPrivateAPIs is _**not**_ a project to document Apple's Private Apis and publi
### SwiftUI

- <doc:ViewModifier>

### NSObject

- <doc:ByDevice>

0 comments on commit 8415912

Please sign in to comment.