错误:“没有更多上下文,表达式类型不明确" [英] Error: 'Type of expression is ambiguous without more context'
本文介绍了错误:“没有更多上下文,表达式类型不明确"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 Swift 编码很陌生,所以如果这个错误是一个简单的答案,请原谅!
I'm pretty new to coding Swift, so please excuse me if this error is a simple answer!
我不断收到一条错误消息,指出没有更多上下文,表达式类型不明确."
I keep getting an error message that says "Type of expression is ambiguous without more context."
var findTimelineData: PFQuery = PFQuery(className: "Sweets")
findTimelineData.findObjectsInBackgroundWithBlock {
(objects:[AnyObject]?, error:NSError?) -> Void in
if error == nil {
for object:PFObject in objects! { // ----This is the error line---
self.timelineData.addObject(object)
}
}
}
有什么建议吗?
谢谢!
推荐答案
你可以帮助编译器知道objects
是这样的:
You can help the compiler know what objects
is like this:
for object in objects as! [PFObject] {
self.timelineData.addObject(object)
}
这篇关于错误:“没有更多上下文,表达式类型不明确"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文