几个月后我回到了我的旧 XCode 项目,现在我遇到了很多以前没有的错误,我认为这与更新的语法有关。
为什么我会看到:
Type of expression is ambiguous without more context
对于这个 block
@IBAction func submitUrl(sender: UIButton) {
var app = UIApplication.sharedApplication().delegate as! AppDelegate
//Error occurs in below declaration of studentDict
var studentDict = ["latitude": self.latitude, "longitude": self.longitude, "firstName": app.firstName, "lastName": app.lastName, "mediaURL": urlField.text]
var studentInfo = StudentInformation(data: studentDict as! [String : AnyObject])
ParseClient.sharedInstance().postStudent(studentInfo, mapString: self.mapString){(success,data) in
if(success){
self.dismissViewControllerAnimated(true, completion: nil)
}
else{
Shared.showError(self,errorString: data["ErrorString"] as! String)
}
}
}
我尝试了 studentDict:NSArray
和 studentDict:Dictionary
因为我认为它无法正确解释 studentDict
中的内容,但是那没有帮助。到底是什么错误告诉我我失踪了?
最佳答案
您初始化时使用的一个或多个值可能是可选的,因此可以为零。这就是您收到此错误的原因
var studentDict:[String:AnyObject?] = ["latitude": self.latitude, "longitude": self.longitude, "firstName": app.firstName, "lastName": app.lastName, "mediaURL": urlField.text]
关于ios - 不清楚 "Type of expression is ambiguous without more context"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33158125/