I've noticed when I have an array of data like my imageArray below, if I explore the data stored locally by the simulator, the array doesn't seem to be stored in extern storage. I come to this conclusion because if I look at the Application Support directory & try to find the ".default_SUPPORT" hidden folder, it's not there. If I were to simply create a model of single images, each of the single images is saved in a ".default_SUPPORT" that I can see. So I'm not sure if setting up .externalStorage with an array of images is doing anything. I'd be curious if anyone has thoughts. Here is the struct I'm using that's working with my app, but that doesn't seem to actually be saving the array of images in .externalStorage, or so I've concluded due to the lack of the hidden ".default_SUPPORT" directory.:
import Foundation
import SwiftData
@Model
class Place {
var city: String
var country: String?
@Attribute(.externalStorage) var imageArray: [Data?]
init(city: String, country: String? = nil, imageArray: [Data?] = []) {
self.city = city
self.country = country
self.imageArray = imageArray
}
}
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: