Kody R. Kody R. - 5 months ago 35
Swift Question

Error: 'Type of expression is ambiguous without more context'

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

I understand what the problem is, I'm just not certain how to go about fixing it. I've seen other questions about this answered, but none about iterating through an array of AnyObject.



You can help the compiler know what objects is like this:

for object in objects as! [PFObject] {