(NSObject,AnyObject)不能转换为DictionaryIndex <nsobject,anyobject =“”> </nsobject,>

时间:2015-01-02 19:00:56

标签: ios swift parse-platform

我正在尝试从Objective-C教程转换此委托协议函数,但是尝试通过使用下标来根据键返回值来尝试访问字典中的值时遇到错误。我不太清楚这里的错误意味着什么。任何帮助将不胜感激!

// 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
}

1 个答案:

答案 0 :(得分:3)

您没有发表声明。但是你可以用以下方法解决它:

for (key, field) in info {
  if field.isEmpty {
    informationComplete = false
    break
  }
}