3

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 Answer 1

7

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)
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.