Relative Content

Tag Archive for iosswiftdataimagepickerphotosui

SwiftData Can’t Use PhotosPickerItem as Property

I’m trying to find a way to reference photos in the User Photos Library and add those references in a SwiftData record. I can, of course, get the photos from the library, convert to Data type and store that in SwiftData, but I’m trying to avoid duplicating all that data (there will be a lot of photos). I thought I should be able to get a URL for a Photos item, but have not found any way to do that. I tried making a property in the SwiftData model for [PhotosPickerItem] but that fails with the error: “Referencing instance method ‘setValue(forKey:to:)’ on ‘Array’ requires that ‘PhotosPickerItem’ conform to ‘PersistentModel'” in the model initializer.