我正在从Objective教程中转换这个委托协议函数,但是遇到了一个错误,试图通过使用下标返回基于键的值来访问字典中的值。我不太清楚这里的错误意味着什么。任何帮助都将不胜感激!
// 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
}
发布于 2015-01-02 11:06:41
你没有发表你的声明。但很可能你可以通过以下方法解决这个问题:
for (key, field) in info {
if field.isEmpty {
informationComplete = false
break
}
}
https://stackoverflow.com/questions/27747173
复制相似问题