Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with NSLog with Swift 3

Tags:

ios

swift3

After migrating to Swift 3, I get an error when I try and do:

self.publicDB.save(listRecord, 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.

like image 463
BlackHatSamurai Avatar asked Oct 12 '16 01:10

BlackHatSamurai


1 Answers

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.

like image 141
matt Avatar answered Oct 13 '22 01:10

matt