Post

Replies

Boosts

Views

Activity

Reply to How to delete 'Disk not ejected properly'
I have noticed this behaviour recently after upgrading to macOS 13.4, where external drives are disconnected due to the Thunderbolt ports going to sleep when the laptop goes to sleep for an extended period. The option to not turn off hard drives seems to only apply to internal drives/SSD and not externally attached drives. You might needs to file a bug via the feedback app.
Topic: App & System Services SubTopic: Hardware Tags:
Jun ’23
Reply to Using swift or other tool to tell if printer is connected and ready for prints
This will only be true or false if a printer is defined and available and the NSPrinter.printerNames list is non-empty. func isConnectedToPrinter() -> Bool { let printers = NSPrinter.printerNames return !printers.isEmpty } see this GitHub resource on how to query the info you're seeking. https://github.com/marc-medley/004.42Apple_CorePrintingExample/blob/3481a1c8c253f98bbff19741a13cd2c9b8d1d88b/PDFPagePrinter/PDFPagePrinter/PrintData.swift#LL190C9-L203C10 // Printer State var printerState: PMPrinterState = 0 let _ = PMPrinterGetState(pmPrinter, &printerState) d["printerState"] = printerState switch printerState { case UInt16(kPMPrinterIdle) : d["printerStateName"] = "kPMPrinterIdle" case UInt16(kPMPrinterProcessing) : d["printerStateName"] = "kPMPrinterProcessing" case UInt16(kPMPrinterStopped) : d["printerStateName"] = "kPMPrinterStopped" default: d["printerStateName"] = "UNSPECIFIED" } Sean
Topic: UI Frameworks SubTopic: AppKit Tags:
May ’23
Reply to Binding with optional Value causes runtime crash
The property is already a published entity in an observable object. Any changes to the name property will be propagated to the SwiftUI view. The issue was your nameBinding property. Unwrapping viewModel.name is you really had to do then passed the value into a Binding init constant as seen here ChildView(selectedName: .constant(name)). struct ParentView: View { @StateObject var viewModel = Model() var body: some View { VStack(alignment: .leading, spacing: 8) { Text("Name is \(viewModel.name ?? "nil")") Button("Make name nil") { viewModel.makeNameNil() } if let name = viewModel.name { ChildView(selectedName: .constant(name)) } } .padding() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23