0
我正在從Objective-C教程轉換此委託協議功能,但遇到了一個錯誤,試圖通過使用下標返回基於密鑰的值。我不太確定這裏的錯誤是什麼意思。任何幫助將不勝感激!(NSObject,AnyObject)is not convertible to DictionaryIndex <NSObject,AnyObject>
// Sent to the delegate to determine whether the sign up request should be submitted to the server
func signUpViewController(signUpController: PFSignUpViewController!, shouldBeginSignUp info: [NSObject : AnyObject]!) -> Bool {
var informationComplete: Bool = true
// Loop through all of the submitted data
for key in info {
var field: String = info[key] // Error occurs at this line on info
if field.isEmpty {
informationComplete = false
break
}
}
// Display an alert if a field was not completed
if !informationComplete {
let alertView: UIAlertView = UIAlertView(title: "Missing Information", message: "Please make sure all information is filled out!", delegate: nil, cancelButtonTitle: "ok")
}
return informationComplete
}
我改變了代碼和錯誤都走了,但我不得不改變'如果field.isEmpty'爲'如果field.isEmpty == nil'否則有一個:但是有可能你可以解決它錯誤。所以從理論上講,這隻會循環通過每個鍵 - 值對,如果其中一個丟失了,它會引發錯誤?那是我正在尋找的 – SamG
是的。用這個簡短的語法得到鍵/值對是一種很好的語言結冰。 –
好的,謝謝!我接受了你的答案,再次看了它之後,我記得在聖誕節的Swift by Tutorials書中看到了類似這樣的東西。應該認識到哈哈。再次感謝! – SamG