簡體   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