Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created April 11, 2023 00:54
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/54afb8b2343b7210fd1ebfad2f4b7098 to your computer and use it in GitHub Desktop.
Save sturdysturge/54afb8b2343b7210fd1ebfad2f4b7098 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@State var number = 0
@State var text = ""
@State var viewHasAppeared = false
func printRefresh() {
if viewHasAppeared {
print("View was refreshed with number '\(number)' and text '\(text)'")
} else {
print("View appeared with number '\(number)' and text '\(text)'")
}
}
var body: some View {
Form {
let _ = printRefresh()
Stepper("Number", value: $number)
TextField("", text: $text)
}
.onAppear { viewHasAppeared = true }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment