简体   繁体   English

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

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

I was working on converting this delegate protocol function from an Objective-C tutorial, but ran into an error trying to access the values in a dictionary by using the subscript to return the value based on the key. 我当时正在从Objective-C教程转换此委托协议函数,但是在尝试使用下标返回基于键的值来访问字典中的值时遇到错误。 I am not quite sure what the error here means. 我不太确定这里的错误是什么意思。 Any help would be greatly appreciated! 任何帮助将不胜感激!

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

You did not post your declaration. 您没有发布声明。 But likely you can solve it with: 但是可能您可以使用以下方法解决它:

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

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

相关问题 &#39;[NSObject]&#39; 不能转换为 &#39;[AnyObject]&#39; - '[NSObject]' is not convertible to '[AnyObject]' `NSDictionary`不能隐式转换为`[NSObject:AnyObject]` - `NSDictionary` is not implicitly convertible to `[NSObject : AnyObject]` “ AnyObject”与“ [NSObject:AnyObject]”不同 - 'AnyObject' is not identical to '[NSObject : AnyObject]' 字符串不可转换为DictionaryIndex <String, AnyObject> - String not convertible to DictionaryIndex<String, AnyObject> 在Swift中将[NSObject,AnyObject]转换为[String,AnyObject] - Converting [NSObject, AnyObject] to [String, AnyObject] in Swift Swift-[NSObject:AnyObject]! 不是“字典”的子类型 <String, AnyObject> - Swift - [NSObject : AnyObject]!' is not a subtype of 'Dictionary<String, AnyObject> [NSObject:AnyObject]和swift中的AnyObject有什么区别 - What is difference between [NSObject: AnyObject] and AnyObject in swift Swift 2.0 - Google Analytics事件构建器错误 - NSMutableDictionary无法转换为[NSObject:AnyObject] - Swift 2.0 - Google Analytics Event builder error - NSMutableDictionary is not convertible to [NSObject : AnyObject] 无法将类型 [NSObject : AnyObject] 转换为字符串 - Cannot convert the type [NSObject : AnyObject] to string swift3中的编译错误:“ AnyObject”不是“ NSObject”的子类型 - Compilation error in swift3: 'AnyObject' is not a subtype of 'NSObject'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM