BlackHatSamurai BlackHatSamurai - 1 year ago 667
iOS Question

Issue with NSLog with Swift 3

After migrating to Swift 3, I get an error when I try and do:, completionHandler: { (record, error) -> Void in
if let saveError = error {
NSLog("There was an error saving the record: %@", saveError)

Can someone tell me why this is and what I can do produce an output with relative ease?

The error is
NSLog unavailable: variadic function unavailable

Answer Source

The problem, despite the "variadic" red herring, is that we no longer get automatic bridging to an Objective-C type; you have to cross the bridge explicitly, yourself. Write saveError as NSError to get an Objective-C style object.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download