Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Created March 3, 2021 08:26
Show Gist options
  • Save prafullakumar/db9e95d184151323e9e9c377acd8d1b6 to your computer and use it in GitHub Desktop.
Save prafullakumar/db9e95d184151323e9e9c377acd8d1b6 to your computer and use it in GitHub Desktop.
final class ContentViewModel: NSObject, ObservableObject {
@Published var errorMessage: String?
@Published var imageArray: [UIImage] = []
}
struct ContentView: View {
@ObservedObject var viewModel: ContentViewModel
var body: some View {
NavigationView {
List {
if let error = viewModel.errorMessage {
Text(error)
} else {
ForEach(viewModel.imageArray, id: \.self) { image in
Image(uiImage: image)
.resizable()
.aspectRatio(contentMode: .fit)
}
}
}.navigationTitle("Vinson kit Demo")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment