mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Somewhat working file tray
This commit is contained in:
parent
4c7e79b954
commit
30422c3d95
29 changed files with 4032 additions and 65 deletions
28
DynamicIsland/helpers/AssociatedObject.swift
Normal file
28
DynamicIsland/helpers/AssociatedObject.swift
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// AssociatedObject.swift
|
||||
// DynamicIsland
|
||||
//
|
||||
// Helper for retaining objects via Objective-C associated storage.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import ObjectiveC
|
||||
|
||||
public struct AssociatedObject<Value: AnyObject> {
|
||||
private let key: UnsafeRawPointer
|
||||
private let policy: objc_AssociationPolicy
|
||||
|
||||
public init(_ policy: objc_AssociationPolicy = .OBJC_ASSOCIATION_RETAIN_NONATOMIC) {
|
||||
self.key = UnsafeRawPointer(Unmanaged.passUnretained(UniqueKey()).toOpaque())
|
||||
self.policy = policy
|
||||
}
|
||||
|
||||
private final class UniqueKey {}
|
||||
|
||||
public subscript<Owner: AnyObject>(_ owner: Owner) -> Value? {
|
||||
get { objc_getAssociatedObject(owner, key) as? Value }
|
||||
nonmutating set { objc_setAssociatedObject(owner, key, newValue, policy) }
|
||||
}
|
||||
}
|
||||
|
||||
extension AssociatedObject: @unchecked Sendable where Value: Sendable {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue