I am trying to get the list of printers using NSPrinter.printerNames, but it doesn't return any items.
static func getPrinterList() -> [(name: String, isAvailable: Bool)] {
let printerNames = NSPrinter.printerNames
return printerNames.map { name in
let isAvailable = NSPrinter(name: name) != nil
return (name: name, isAvailable: isAvailable)
}
}
The printerNames is a empty string array.
I checked the settings for printers and screens, and there is a printer device listed.
I need to set something else?
I think you’re hitting a sandbox restriction. I put your code into a non-sandboxed app and it works as expected:
[(name: "Darth Inker", isAvailable: true)]
But if I then enable the App Sandbox I get the empty list back.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"