Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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