getting unresolved identifier 'self' in SwiftUI code trying to use Timer.scheduledTimer
问题 In SwiftUI I'm noting to use a Timer that: Try 1 - This doesn't work as get "Use of unresolved identifier 'self'" var timer2: Timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { self.angle = self.angle + .degrees(1) } Try 2 - Works, but have to put in an "_ = self.timer" to start it later var timer: Timer { Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) {_ in self.angle = self.angle + .degrees(1) } } // then after need to use " .onAppear(perform: {_ = self.timer}) "