#16: Structs in SwiftUI
Question
// Swift Quiz
— objc.io (@objcio) June 5, 2019
import SwiftUI
struct Objcio: View {
var book: String
var body: some View {
Text(book)
}
}
var objcio = Objcio(book: "App Architecture")https://t.co/CvLtyOUb4c = "Advanced Swift"
// What text will be on screen?
Solution
Solution: Advanced Swift
— objc.io (@objcio) June 6, 2019
Because Objcio is just a regular struct, the book property changes as expected.
The moment it gets rendered, SwiftUI looks at the current value (“Advanced Swift”) and renders that.https://t.co/s7500CWmAg