Skip to content

SwiftUI gets used a lot with Struct

   

SameID

This was avoided by regenerating the id with onDisappear.
If there is no change in @State, does that mean that you use the cache?
I'm going to learn more about it!

SameID

import SwiftUI
struct ContentView_20191114: View {
@State var id = UUID().uuidString
var body: some View {
VStack {
NavigationLink(destination: DetailView_20191114(hoge: Hoge(id: id))) {
Text("Tap Me!")
.font(.title)
}
}.onDisappear {
self.id = UUID().uuidString
}
}
}
struct DetailView_20191114: View {
var hoge: Hoge
var body: some View {
Text("id: \(hoge.id)")
}
}
struct Hoge {
var id: String
}
struct ContentView_20191114_Previews: PreviewProvider {
static var previews: some View {
ContentView_20191114()
}
}
import SwiftUI
struct ContentView_20191114: View {
var body: some View {
VStack {
NavigationLink(destination: DetailView_20191114(hoge: Hoge())) {
Text("Tap Me!")
.font(.title)
}
}
}
}
struct DetailView_20191114: View {
var hoge: Hoge
var body: some View {
VStack {
Text("id: \(hoge.id)")
}
}
}
struct Hoge {
var id: String = UUID().uuidString
}
struct ContentView_20191114_Previews: PreviewProvider {
static var previews: some View {
ContentView_20191114()
}
}

  1. Displaying a List in SwiftUI
  2. Sending push notifications to your app with cURL (curl)
  3. Retrieving a certificate and private key from a P12 file
  4. Update cocoapods installed with gem.
  5. I had a chance to speak at iOSDCJapan2019 Day 1 in the Rookies LT slot.
  6. Changing the height of a TableView cell (Swift5.0.1)
  7. UIButton, display a button (Swift5.0)