I'm using Apple's VisionKit and storing the images in both an Image and Data array, like so:
@State private var image: [Image] = []
@State var imageData : Data = .init(count: 0)
And appending the data like this:
for imageIndex in imagePerPage! {
var uiImage = UIImage(cgImage: imageIndex)
let converted = Image(uiImage: uiImage)
image.append(converted)
imageData.append(uiImage.jpegData(compressionQuality: 0.00005)!)
}
I'm passing the data to another view which is fine, as I can use print(image.count) and I get the expected count. However, I'm having issues with iterating over my array and display the images. I use a ForEach statement and I get an error nagging me that the data type Image must conform to Hashable (I'm not using a model/struct)
@State var image: [Image]
ForEach(image.count, id: \.self) { image in
Image(image)
.resizable()
.frame(width: getScreen().width, height: getScreen().height * 0.85)
.aspectRatio(contentMode: .fit)
}
I've even tried a for loop i.e. for x in images {///}.
Is there anyway in which I can resolve this issue?
Would be much appreciated!