繁体   English   中英

(NSObject,AnyObject)不能转换为DictionaryIndex <NSObject, AnyObject>

[英](NSObject, AnyObject) is not convertible to DictionaryIndex<NSObject, AnyObject>

我当时正在从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
}

您没有发布声明。 但是可能您可以使用以下方法解决它:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM