Search code examples
xcodeswiftxcode7swift3

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


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

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

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()
}

Solution

  • 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()
    }