Yes, it is possible to use Swift to get the printing process on a Mac and receive a notification when it is finished. You can use the NSPrintOperation class to start a print job and the NSPrintOperationDidRunNotification notification to receive a notification when the print job is complete. Here's an example:
let printInfo = NSPrintInfo.shared
let printOp = NSPrintOperation(view: myView, printInfo: printInfo)
NotificationCenter.default.addObserver(forName: NSPrintOperationDidRunNotification,
object: printOp,
queue: nil) { notification in
print("Printing finished!")
}
printOp.run()
In this example, myView
is the view you want to print. Once you start the print operation with printOp.run()
, you will receive a notification when it finishes.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-06 09:29:37 +0000
Seen: 9 times
Last updated: Jun 06 '23
How to add a custom button in SwiftUI for iOS13 that enables going back between screens?
How can the update of properties from both ParentViewModel and ChildViewModel in SwiftUI be solved?
Can SwiftUI be utilized to restrict the touch region for a drag gesture?
How can the color of a selected element (Picker) be modified in SwiftUI for WatchOS?
How to make a calendar layout that is horizontal using Swiftui?
What is the process to add a radio button with a check mark on a TableView cell using Swift?
How to limit UITextField input to only accept numerical values?