Posts

Post not yet marked as solved
0 Replies
402 Views
Hello,i am new to SwiftUI on macos and running into a problem.I would like to load an external image to my view. Image() itself only loads images within the bundle.Which function should i use to load an image from a file:///Volumes/... URL?I tried Image(nsImage: NSImage(named: self.flickrImageName)!) .frame(width: 500, height: 200) .background(Color.green)with flickrimageName = "file:///Volumes/...image.jpg"It compiles, but crashes on execution.2020-01-02 12:08:45.747535+0100 MKFlickrRead[4462:130911] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/kochma/Documents/Sources/Swift/MKFlickrRead/MKFlickrRead/ContentView.swift, line 19Where do i go wrong
Posted
by mkoch66.
Last updated
.
Post marked as solved
2 Replies
1.2k Views
I followed the instructions in this tutorial. https://developer.apple.com/tutorials/swiftui/creating-and-combining-viewsMy problem is that i cannot see the canvas to press resume. I can run the code on the simulator, but the canvas does not show up. Even after switching to "Editor only" and back to "Editor & Canvas". Where do i go wrong?Secondly XCode11 generates a if DEBUG block around the second block of code in ContentView.swift. This is different in the tutorial.Like:#if DEBUGstruct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() }}#endifI am using XCode11 Beta M11336w on an iMac2017 with Mojave with all normal updates installed.
Posted
by mkoch66.
Last updated
.