How to display image from known image path - SwiftUI

Viewed 793

I've got an array of image URLs (all from storage, not internet). How can I show the images themselves? Simplified code:

@Binding var files:[URL]//Array of image URLs taken from an NSOpenPanel instance

Form{
    if files.count>0{
        Image(files[0].path)//Problem
    }
}
1 Answers

You say NSOpenPanel, so I'm making going to make the assumption here that we don't need to worry about waiting to load the image over a network:

if let nsImage = NSImage(contentsOf: url) {
  Image(nsImage: nsImage)
}
Related