Last active
March 19, 2025 06:58
-
-
Save gaeng2y/328c990deefa0cbe0966c5bb62fefa32 to your computer and use it in GitHub Desktop.
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
| func fetchOneThumbnail(withID id: String) async throws -> UIImage { | |
| let imageReq = imageRequest(for: id), metadataReq = metadataRequest(for: id) | |
| let (data, _) = try await URLSession.shared.data(for: imageReq) | |
| let (metaData, _) = try await URLSession.shared.data(for: metadataReq) | |
| guard let size = parseSize(from: metadata), | |
| let image = await UIImage(data: data)?.byPreparingThumbnail(ofSize: size) | |
| else { | |
| throw ThumbnailFailedError() | |
| } | |
| return Image | |
| } | |
| // async-let | |
| func fetchOneThumbnail(withID id: String) async throws -> UIImage { | |
| let imageReq = imageRequest(for: id), metadataReq = metadataRequest(for: id) | |
| async let (data, _) = URLSession.shared.data(for: imageReq) | |
| async let (metaData, _) = URLSession.shared.data(for: metadataReq) | |
| guard let size = parseSize(from: try await metadata), | |
| let image = try await UIImage(data: data)?.byPreparingThumbnail(ofSize: size) | |
| else { | |
| throw ThumbnailFailedError() | |
| } | |
| return Image | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment