NSLog in Swift

I'm having trouble translating Objective-C sample from documentation into Swift. Here is the Objective-C code I'm trying to translate:


void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =

^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {

if(!completed && error){

NSLog(@"FAILED! due to error in domain %@ with error code %u",

error.domain, error.code);

}


So fat I have translated that to this Swift code:


let completionHandler: UIPrintInteractionCompletionHandler = {

(controller: UIPrintInteractionController, completed: Bool, error: Error) in

if (!completed && error) {

}

}


The part I don't know how to translate is the use of NSLog. Should I use NSLog in my Swift code?

Answered by Claude31 in 230384022

In Swift I just use print() or Swift.print()


Swift.print("FAILED! due to error in domain \(error.domain) with error code \(error.code))

Accepted Answer

In Swift I just use print() or Swift.print()


Swift.print("FAILED! due to error in domain \(error.domain) with error code \(error.code))

NSLog in Swift
 
 
Q