Skip to content

Commit

Permalink
Update PHPicker.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzukihashi committed May 18, 2024
1 parent 30eed81 commit bd257f7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/ImagePickerSwiftUI/PHPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ public struct PHPicker: UIViewControllerRepresentable {
for result in results {
do {
let image = try await loadImage(result: result)
let videoURL = try await loadVideo(result: result)
if let videoURL = try await loadVideo(result: result) {
parent.videoURLs.append(videoURL)
}

parent.images.append(image)
parent.videoURLs.append(videoURL)

} catch {
print(error.localizedDescription)
}
Expand All @@ -66,7 +68,7 @@ public struct PHPicker: UIViewControllerRepresentable {
}
}

private func loadVideo(result: PHPickerResult) async throws -> URL {
private func loadVideo(result: PHPickerResult) async throws -> URL? {
try await withCheckedThrowingContinuation { continuation in
let provider = result.itemProvider

Expand All @@ -84,7 +86,7 @@ public struct PHPicker: UIViewControllerRepresentable {
}
}

continuation.resume(throwing: ImagePickerError.missingImage)
continuation.resume(returning: nil)
}
}

Expand Down

0 comments on commit bd257f7

Please sign in to comment.