Post

Replies

Boosts

Views

Activity

SwiftUI - Infinite Loop - onDisappear without "."
Issue In Xcode version 15.1 iOS Version 16.6 Very strange, the following code create a never ending loop if I miss a single dot(.) in the syntax. You can see the "onAppear" message in the log. Somehow the compiler also not showing any error or warning. With my limited knowledge , I feel it's a kind of a bizard in any programming language. Think about the possible regression issues in complex projects due to this. And we will not get any build issues also. Please correct me if I am doing something wrong here. There are other similar issues like this, but I think I am able to reproduce this by removing a dot "." Code with issue .onAppear() { subscribeListeners() Logger.shared.debug("DownloadDataView: onAppear") } onDisappear() { unsubscribeListeners() } Correct code .onAppear() { subscribeListeners() Logger.shared.debug("DownloadDataView: onAppear") } .onDisappear() { unsubscribeListeners() } Xcode version 15.1 iOS Version 16.6
2
1
682
Dec ’23
Getting Raw Gyroscope Events not working in WatchOS 9.1
I was following the below documentation for getting the Raw Gyroscope events. Somehow I am unable to make the below code working. if motion.isGyroAvailable { self.motion.gyroUpdateInterval = 1.0 / 60.0 self.motion.startGyroUpdates() // Configure a timer to fetch the accelerometer data. self.acceTimer = Timer(fire: Date(), interval: (1.0/60.0), repeats: true, block: { (timer) in // Get the gyro data. if let data = self.motion.gyroData { let x = data.rotationRate.x let y = data.rotationRate.y let z = data.rotationRate.z // Use the gyroscope data in your app. print("rotationX: \(x) , rotationY: \(y) , rotationZ: \(z)") } }) // Add the timer to the current run loop. RunLoop.current.add(self.acceTimer!, forMode: .default) } https://developer.apple.com/documentation/coremotion/getting_raw_gyroscope_events The isGyroAvailable always returns false Dev environment - Xcode 14.1, Apple Watch 8, WatchOS 9.1
1
0
1.5k
Nov ’22