不推荐使用“var"参数,并将在 Swift 3 中删除 [英] 'var' parameters are deprecated and will be removed in Swift 3

查看:33
本文介绍了不推荐使用“var"参数,并将在 Swift 3 中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我只是将 Xcode 更新到 7.3,现在我收到了这个警告:

Alright so I just update Xcode to 7.3 and now I get this warning:

'var' 参数已弃用,将在 Swift 3 中删除

'var' parameters are deprecated and will be removed in Swift 3

当我需要在这个函数中使用 var 时如何解决这个问题:

How to fix this when I need to use the var in this function:

public func getQuestionList(var language: String) -> NSArray {
    if self.data.count > 0 {
        if (language.isEmpty) {
            language = "NL"
        }
        return self.data.objectForKey("questionList" + language) as! NSArray
    }

    return NSArray()
}

推荐答案

是否尝试分配给新的 var

Have you tried to assign to a new var

public func getQuestionList(language: String) -> NSArray {
    var lang = language
    if self.data.count > 0 {
        if (lang.isEmpty) {
            lang = "NL"
        }
        return self.data.objectForKey("questionList" + lang) as! NSArray
    }

    return NSArray()
}

这篇关于不推荐使用“var"参数,并将在 Swift 3 中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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