I checked with a colleague and they agreed that my theory above is correct
So if the expected behavior is:
According to my theory, I don't believe the @State has actually been initialized at this point, so your call to start() actually initializes a Timer, starts it, and then as soon as that scope exits ARC destroys that Timer.
Then, a little bit later, the @State managed Timer is actually created, resulting in these logs:
ObjectIdentifier(0x0000000a22a2ca80) init ObjectIdentifier(0x0000000a22c245a0) stop
And the "bad" example from TN3211 is:
struct ContentView: View {
@State private var counter: Int = 0
init() {
self.counter = 42
}
}
I kind of start to think here that if State has an inline initial value and the developer attempts to set a value in init we want to either crash at runtime or at least try to display one of those purple warnings in Xcode.
Something other than just sort of failing silently might be a very good idea here considering all the code that is probably out there either using this example from TN3211 or my example.