|
|
@@ -28,7 +28,7 @@ import Foundation
|
|
|
|
|
|
#if os(iOS) || os(macOS) || os(visionOS)
|
|
|
|
|
|
-import PhotosUI
|
|
|
+@preconcurrency import PhotosUI
|
|
|
|
|
|
/// A data provider to provide image data from a given `PHPickerResult`.
|
|
|
@available(iOS 14.0, macOS 13.0, *)
|
|
|
@@ -37,6 +37,8 @@ public struct PHPickerResultImageDataProvider: ImageDataProvider {
|
|
|
/// The possible error might be caused by the `PHPickerResultImageDataProvider`.
|
|
|
/// - invalidImage: The retrieved image is invalid.
|
|
|
public enum PHPickerResultImageDataProviderError: Error {
|
|
|
+ /// An error happens during picking up image through the item provider of `PHPickerResult`.
|
|
|
+ case pickerProviderError(Error)
|
|
|
/// The retrieved image is invalid.
|
|
|
case invalidImage
|
|
|
}
|
|
|
@@ -64,10 +66,10 @@ public struct PHPickerResultImageDataProvider: ImageDataProvider {
|
|
|
self.contentType = contentType
|
|
|
}
|
|
|
|
|
|
- public func data(handler: @escaping (Result<Data, Error>) -> Void) {
|
|
|
+ public func data(handler: @escaping @Sendable (Result<Data, Error>) -> Void) {
|
|
|
pickerResult.itemProvider.loadDataRepresentation(forTypeIdentifier: contentType.identifier) { data, error in
|
|
|
if let error {
|
|
|
- handler(.failure(error))
|
|
|
+ handler(.failure(PHPickerResultImageDataProviderError.pickerProviderError(error)))
|
|
|
return
|
|
|
}
|
|
|
|