错误:在类型上使用实例成员

时间:2016-05-01 01:01:03

标签: ios swift function-calls

在下面的代码中,我在"类型上有一个"实例成员;我尝试调用matchTravellerWithLocal函数并将返回值分配给消息时出错。关于如何解决这个错误的任何想法?

var travellerInformation: Traveller{
    return Traveller(destination: location, travellingPreference: preference)
}

let message = matchTravellerWithLocal(travellerInformation)



func matchTravellerWithLocal(traveller: Traveller) -> String {
    var message = ""
    let location =  traveller.destination.rawValue
    let type = traveller.travellingPreference.rawValue
    let locals = LocalsInformation().locals
    for (name, information) in locals{
        let city = information["City"]
        let preference = information["Preference"]
        if city == location{
            message = "Meet your local: \(name), a local of \(city)"
            print(message)
        }else{
            message = "Apologies, there aren't in \(city) on LocalRetreat. Try again soon!"
            break
        }
        if preference == type{
            message += "who is also a \(preference)"
            print(message)
        }
    }
    return message
}

0 个答案:

没有答案