Just updated to XCode 14 this morning and am receiving this strange warning
Result of call to function returning 'Bool' is unused
when working with the present function for printing via AirPrint. This was not an issue in XCode 13 and I cannot see any reason it's happening now, except if something changed in Swift 6.
Hoping someone knows the answer.
Here's the function:
/// Prints the PDF file using airprint
func printPDF() {
let pdfFileURL = FileManager.default.temporaryDirectory.appendingPathComponent(
"Filename.pdf"
)
let printController = UIPrintInteractionController.shared
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print PDF"
printInfo.outputType = .general
printController.printInfo = printInfo
printController.printingItem = pdfFileURL
printController.present(animated: true) { (_, isPrinted, error) in // <-- Result of call to function returning 'Bool' is unused
if error == nil {
if isPrinted {
print("Print Success")
} else {
print("Print Failed: \(error?.localizedDescription ?? "No Error")")
}
}
}
} // End Func
CodePudding user response:
According to the documentation the signature of the function is:
func present(animated: Bool, completionHandler: UIPrintInteractionController.CompletionHandler?) -> Bool
if you don´t need the returned value use:
let _ = printController.present(animated: true) { (_, isPrinted, error) in