Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Toggle multiple times per frame
The workingdogintokyo solution does work. Unfortunately in my case, it would introduce too much bloatware that would be hard to maintain. There's little point in re-factoring only to then start adding loads of extra @Things all over the place So, I've decided to give up with those nice looking Toggles and just use plain old Buttons. They're not as elegant and they can't be customised as much as they can on iOS, but at least they work. I have structs for various devices, but this is the one for the Power Supplies. struct PowerSupplyControl: View {     @Binding var psu: PowerSupplyStatus     @EnvironmentObject var vm: ViewModel     var body: some View {         HStack {             Text(psu.name)             Spacer()             Button(action: {                 vm.request(action: .PSU, param: psu.name)             }, label: {                 Text(psu.isOn ? "ON" : "OFF")                     .foregroundColor(psu.isOn ? .green : .primary)             })             .accentColor(.white)             .frame(width: 40, alignment: .center)             Text(String(format: "%05.2f V", psu.voltage)).frame(width: 50, alignment: .trailing)             Text(String(format: "%05.2f A", psu.current)).frame(width: 50, alignment: .trailing)         }     } } Thanks again for all your time.
Jul ’21
Reply to Integrating NWCAT into SwiftUI
Thank you for this Mathew. I very much appreciate your time. I did go ahead and posted to the Swift forum. In fact, I've been receiving wonderful assistance from Cory Benfiled during the past few hours. Here's the link to issue 50173 where I suggest anyone watching should divert their attention.
Jul ’21
Reply to Integrating NWCAT into SwiftUI
I need direction (or an example) for the 3 questions in the following snippet. Please can you help? import Foundation import NIO import NIOFoundationCompat class NetworkService {     var connected = false // Q1 Are these declarations correct?     var group: MultiThreadedEventLoopGroup     var bootstrap: ClientBootstrap     var channel: Channel?        init() {         self.group = MultiThreadedEventLoopGroup(numberOfThreads: 1)         self.bootstrap = ClientBootstrap(group: group)             .channelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1)             .channelInitializer { channel in                 channel.pipeline.addHandler(ResponseHandler())             }         defer {             try! self.group.syncShutdownGracefully()         }     }     public func connect(host: String, port: Int, completion: (_ success:Bool, _ error:String) -> Void) {         if connected {             completion(false, "ERROR: already connected")             return         }         do { // Q2 How to change to the correct thread - and return to main?             channel = try bootstrap.connect(host: host, port: port).wait()         } catch {             completion(false, "ERROR: NetworkService.connect() failed to connect")             connected = false             return         }         connected = true         completion(true, "")     }     public func disconnect(completion: (_ success:Bool, _ error:String) -> Void) {         if !connected {             completion(false, "ERROR: already disconnected")             return         }         do { // Q3 How to change to the correct thread - and return to main?             try channel?.close().wait()         } catch {             completion(false, "ERROR: NetworkService.disconnect() failed to disconnect")             return         }         connected = false         completion(true, "")     } // // more follows... // Of course, any other suggestions will be most appreciated. Thank you.
Jul ’21
Reply to Xcode 11.5.1 add Package Dependencies not working
SOLVED - with a sledge hammer! First, I copied all Xcode projects to an external disk and unmounted it, then I did a Command-R on reboot and ran First Aid on all 3 APFS partitions. No errors were reported. On restart, I created a new Xcode project and "magic", I was able to add Package Dependencies once again! Perhaps it was because I'd been duplicating some of my folders contain projects - the novice way to create a branch - and that was confusing some of Xcode's undocumented and hard to find files. The real odd thing is, Xcode is now creating an extra Tests folder for Previews (and probably other thing it didn't before). I really wish Apple would concentrate on getting CURRENT things working, including decent documentation and telling us how to create modern Help files (instead of the obsolete ones), before bringing out new Beta versions with even more bugs.
Jun ’21