Swift 3 的 NSLog 问题 [英] Issue with NSLog with Swift 3

查看:25
本文介绍了Swift 3 的 NSLog 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

迁移到 Swift 3 后,当我尝试执行以下操作时出现错误:

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?

错误是NSLog 不可用:可变参数函数不可用.

推荐答案

尽管存在可变参数"红鲱鱼,但问题是我们不再自动桥接到 Objective-C 类型;你必须明确地过桥,你自己.编写 saveError as NSError 以获得一个 Objective-C 风格的对象.

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.

这篇关于Swift 3 的 NSLog 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆