@@ -51,50 +51,19 @@ struct AnyDropDelegate: DropDelegate {
5151 }
5252}
5353
54- extension NSItemProvider : @unchecked Sendable { }
55-
5654extension NSItemProvider {
57- func loadObject< T> ( ofClass: T . Type ) async throws -> T ? where T: NSItemProviderReading {
58- try await withCheckedThrowingContinuation { continuation in
59- _ = loadObject ( ofClass: ofClass) { data, error in
60- if let error {
61- continuation. resume ( throwing: error)
62- return
63- }
64-
65- guard let object = data as? T else {
66- continuation. resume ( returning: nil )
67- return
68- }
69-
70- continuation. resume ( returning: object)
55+ /// Load a file URL from the item provider.
56+ func loadFileURL( completion: @escaping @Sendable ( URL ? ) -> Void ) {
57+ loadItem ( forTypeIdentifier: " public.file-url " , options: nil ) { data, _ in
58+ guard let data = data as? Data ,
59+ let url = URL ( dataRepresentation: data, relativeTo: nil )
60+ else {
61+ completion ( nil )
62+ return
7163 }
64+ completion ( url)
7265 }
7366 }
74-
75- func loadObject< T> ( ofClass: T . Type ) async throws -> T ?
76- where T: _ObjectiveCBridgeable , T. _ObjectiveCType: NSItemProviderReading {
77- try await withCheckedThrowingContinuation { continuation in
78- _ = loadObject ( ofClass: ofClass) { data, error in
79- if let error {
80- continuation. resume ( throwing: error)
81- return
82- }
83-
84- guard let data else {
85- continuation. resume ( returning: nil )
86- return
87- }
88-
89- continuation. resume ( returning: data)
90- }
91- }
92- }
93-
94- /// Get a URL from the item provider, if any.
95- func getURL( ) async -> URL ? {
96- try ? await loadObject ( ofClass: URL . self)
97- }
9867}
9968
10069extension NSSize {
@@ -131,8 +100,9 @@ extension NSSize {
131100 }
132101}
133102
134- extension AVMediaSelectionOption : Identifiable {
135- public var id : String {
103+ extension AVMediaSelectionOption {
104+ /// Provides a stable identifier for the option.
105+ var stableID : String {
136106 let dict = propertyList ( ) as? NSDictionary
137107 guard let dict, let id = dict. value ( forKey: " MediaSelectionOptionsPersistentID " ) as? Int
138108 else {
0 commit comments