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

前端 未结 3 1888
时光取名叫无心
时光取名叫无心 2020-12-17 16:03

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 w

相关标签:
3条回答
  • 2020-12-17 16:38
    if let pfObjects = objects as? [PFObject]
    {
        for pfObject in pfObjects
        {
            self.timelineData.addObject(pfObject)
        }
    }
    

    ...exclamation points in Swift code give me the heeby jeebies.

    0 讨论(0)
  • 2020-12-17 16:45

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

    for object in objects as! [PFObject] {
        self.timelineData.addObject(object)
    }
    
    0 讨论(0)
  • 2020-12-17 17:03

    If you are writing some code likes:

    for (i, view) in views { 
    }
    

    You need to add enumerated:

    for (i, view) in views.enumerated() {
    }
    

    And now it should work.

    0 讨论(0)
提交回复
热议问题