Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created January 5, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/6ea22661cea907d396f891971978a107 to your computer and use it in GitHub Desktop.
Save sturdysturge/6ea22661cea907d396f891971978a107 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@StateObject var dataModel = DataModel()
var body: some View {
if let xkcd = dataModel.xkcd {
Text(xkcd.title)
.onAppear {
dataModel.getImage()
}
if let image = dataModel.image {
Image(uiImage: image)
.resizable()
.scaledToFit()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment