首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >(NSObject,AnyObject)不能转换为DictionaryIndex<NSObject,AnyObject>

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

Stack Overflow用户
提问于 2015-01-02 19:00:56
回答 1查看 475关注 0票数 0

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

代码语言:javascript
代码运行次数:0
运行
复制
// 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
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-02 19:06:41

你没有发表你的声明。但很可能你可以通过以下方法解决这个问题:

代码语言:javascript
代码运行次数:0
运行
复制
for (key, field) in info {
  if field.isEmpty {
    informationComplete = false
    break
  }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27747173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档