10
我有一個嵌入Swift 1.5的項目。當我轉換的代碼,SWIFT 3.0它開始顯示我的錯誤在下面的代碼每個「if」語句:在Swift 3中對成員'下標'的歧義引用
convenience init?(userInfo: [NSObject: AnyObject]) {
guard let statusString = userInfo[ConnectionMessage.StatusKey] as? String else {
return nil
}
guard let status = ConnectionStatus(string: statusString) else {
return nil
}
guard let connectionId = userInfo[ConnectionMessage.ConnectionIdKey]?.longLongValue else {
return nil
}
var ssid = ""
if let newSsid = userInfo[ConnectionMessage.SSIDKey] as? String {
ssid = newSsid
}
var password = ""
if let pw = userInfo[ConnectionMessage.PasswordKey] as? String {
password = pw
}
let buyerName = userInfo[ConnectionMessage.BuyerNameKey] as? String
self.init(status: status, connectionId: connectionId, ssid: ssid, password: password, buyerName: buyerName)
}
的錯誤是
曖昧參考成員標
我試過在StackOverflow找到的解決方案,但沒有運氣。請指導。
謝謝。得到它了。你能解釋一下爲什麼它在以前版本的swift中工作,爲什麼現在不工作? – Yogi
我只學過Swift 3.0,所以我不知道它是如何處理舊版本的。 – rmaddy