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
#import <AVFoundation/AVFoundation.h> | |
#import <VideoToolbox/VideoToolbox.h> | |
@interface AVPlayerVideoOutput (Category) | |
@property (class, nonatomic, readonly) BOOL cp_isSupported; | |
@end | |
@implementation AVPlayerVideoOutput (Category) | |
+ (BOOL)cp_isSupported { |
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
#import <AVFoundation/AVFoundation.h> | |
@interface Observer: NSObject | |
@end | |
@implementation Observer | |
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { | |
if ([object isKindOfClass:[AVPlayer class]]) { | |
if ([keyPath isEqualToString:@"currentItem"]) { | |
AVPlayerItem * _Nullable oldPlayerItem = change[NSKeyValueChangeOldKey]; | |
if (oldPlayerItem) { |
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
import SwiftUI | |
import RealityKit | |
import Darwin.POSIX.dlfcn | |
struct ContentView: View { | |
var body: some View { | |
NavigationStack { | |
NavigationLink("Push") { | |
RealityView { _ in} | |
.onDisappear { |
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
import Darwin.POSIX.dlfcn | |
import ObjectiveC.runtime | |
func foo() { | |
let handle = dlopen("/System/Library/Frameworks/TVServices.framework/TVServices", RTLD_NOW) | |
assert(handle != nil) | |
let TVSDevice: AnyClass = objc_lookUpClass("TVSDevice")! | |
let supportsUltrawide_method = class_getClassMethod(TVSDevice, Selector(("supportsUltrawide")))! |
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
import Photos | |
extension PHImageManager { | |
func requestImage( | |
for asset: PHAsset, | |
targetSize: CGSize, | |
contentMode: PHImageContentMode, | |
options: PHImageRequestOptions?, | |
bufferingPolicy limit: AsyncThrowingStream<(UIImage?, [AnyHashable : Any]?), any Error>.Continuation.BufferingPolicy = .unbounded | |
) -> (stream: AsyncThrowingStream<(UIImage?, [AnyHashable : Any]?), any Error>, requestID: PHImageRequestID) { |
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
@preconcurrency import Foundation | |
extension _KeyValueCodingAndObserving { | |
func observe<Value>( | |
_ keyPath: KeyPath<Self, Value>, | |
options: NSKeyValueObservingOptions = [], | |
bufferingPolicy limit: AsyncStream<NSKeyValueObservedChange<Value>>.Continuation.BufferingPolicy = .unbounded | |
) -> AsyncStream<NSKeyValueObservedChange<Value>> { | |
let (stream, continuation) = AsyncStream<NSKeyValueObservedChange<Value>>.makeStream(bufferingPolicy: limit) | |
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 final class SerialExecutorToTaskExecutor: TaskExecutor { | |
private let unownedSerialExecutor: UnownedSerialExecutor | |
init(unownedSerialExecutor: UnownedSerialExecutor) { | |
self.unownedSerialExecutor = unownedSerialExecutor | |
} | |
func enqueue(_ job: consuming ExecutorJob) { | |
job.runSynchronously(on: unownedSerialExecutor) | |
} |
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
import Foundation | |
extension _KeyValueCodingAndObserving { | |
func observe<Value>( | |
_ keyPath: KeyPath<Self, Value>, | |
options: NSKeyValueObservingOptions = [], | |
bufferingPolicy limit: AsyncStream<NSKeyValueObservedChange<Value>>.Continuation.BufferingPolicy = .unbounded | |
) -> AsyncStream<NSKeyValueObservedChange<Value>> { | |
guard !options.contains(.initial) else { fatalError() } | |
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
extension AsyncStream.Continuation.BufferingPolicy: @retroactive @unchecked Sendable {} | |
final class SerialExecutorToTaskExecutor: TaskExecutor { | |
private let unownedSerialExecutor: UnownedSerialExecutor | |
init(unownedSerialExecutor: UnownedSerialExecutor) { | |
self.unownedSerialExecutor = unownedSerialExecutor | |
} | |
func enqueue(_ job: consuming ExecutorJob) { |
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
@_rawLayout(like: Bool) | |
struct ManyBools: ~Copyable { | |
static let max = MemoryLayout<Bool>.stride * 8 | |
subscript(_ index: Int) -> Bool { | |
get { | |
guard (0..<ManyBools.max).contains(index) else { fatalError() } | |
return withUnsafeBytes(of: self) { ptr in | |
ptr |