Post

Replies

Boosts

Views

Activity

Reply to Can I detect wifi status on/off in iOS
Reachability is deprecated. You can use NWPathMonitors to monitor the WiFi and Cellular connections. A closure is called every time the connection status changes. (The monitoring takes place on a background thread, so you need to dispatch the UI updates on the main thread.) Setup: import NetworkExtension private let monitorWiFi = NWPathMonitor(requiredInterfaceType: .wifi) Monitor: monitorWiFi.pathUpdateHandler = { path in /// This closure is called every time the connection status changes DispatchQueue.main.async { switch path.status { case .satisfied: print("PathMonitor WiFi satisfied, interface: \(path.availableInterfaces) gateways: \(path.gateways)") default: print("PathMonitor WiFi not satisfied: \(path.unsatisfiedReason)") } } } monitorWiFi.start(queue: DispatchQueue(label: "monitorWiFi"))
Jul ’21
Reply to Initializing a @StateObject from an @EnvironmentObject
Yes, this seems clumsy at the moment. As noted, the environmentObject is not available in init. It is possible to assign a temporary value on declaration: @State private var vm: NewsViewModel = /// some temporary value ...then assign the true value in onAppear: .onAppear { vm = /// it's true value, which can reference the environmentObject } It's not pretty, but it works.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’21
Reply to Char comparison not working
The point being that "a" is not equal to "A"... your test for equality must match the letter case. For better readability, you could try: func wordChained() -> Bool{         if let char1 = prevWord.last?.lowercased(),            let char2 = playerWord.first?.lowercased(),            char1 == char2 {             return true         }         return false     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’21
Reply to SwiftUI Toggle multiple times per frame
Your UI should reflect the state of the PSU. You need to separate out: • A user action sends a command to the PSU. • The app displays the updated PSU state, whenever it is received. Since the PSU can also be switched off (or even on?) outside of the app, you also need to take account of that. That could be achieved (for example) by making the PSU an ObservableObject, and making isOn Published.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’21
Reply to {"timestamp":"2021-07-25 00:49:22.26 -0400","bug_type":"120","os_version":"iPhone OS 12.5 (16H20)","incident_id":"A578AE22-A196-4EB0-A766-33FE1C017FCC"} {"bug_type":"120","os_version":"iPhone OS 12.5 (16H20)"} Incident Identifier: 2684C217-5BBE-43BE-
This is json, so it's easier to read if you lay it out more neatly... { "timestamp":"2021-07-25 00:49:22.26 -0400", "bug_type":"120", "os_version":"iPhone OS 12.5 (16H20)", "incident_id":"A578AE22-A196-4EB0-A766-33FE1C017FCC" } { "bug_type":"120", "os_version":"iPhone OS 12.5 (16H20)" } Incident Identifier: 2684C217-5BBE-43BE- (You seem to have cut it off at this point?) So you have: timestamp: date/time using ISO 8601 format. bug_type: Int. os_version: String. incident_id: UUID.
Jul ’21
Reply to Editor placeholder in source file
newText is an Optional String, so you need to unwrap it, or provide a default value. Maybe... textFieldStrings[index] = newText ?? "some default value" Other than that, you are using several variables where you don't show the declarations. So there could be a problem with one of those?
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’21