PhotosPicker In Production: Load, Downsample, And Save User Media
Read OriginalThis article provides a detailed guide on implementing PhotosPicker in a production SwiftUI app, addressing common pitfalls like handling large HEIC files, downloading from iCloud Photos, and managing multiple selections. It covers loading file representations, copying to app storage, downsampling with ImageIO for previews, and using task cancellation with .task(id:). The example uses iOS 17 and Swift 5.9 features, with notes for older versions. It includes code for an AvatarPickerView and a main actor-isolated view model with importID tokens to prevent stale data.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser
Top of the Week
No top articles yet