Binary operator '..<' cannot be applied to operands of type 'Int' and 'CGFloat'

前端 未结 2 1118
走了就别回头了
走了就别回头了 2020-12-06 19:20

I\'m trying to create a for loop but can\'t seem to understand how to get rid of this error

My code:

for i:CGFloat in 0 ..< 2 + self.frame.size.wi         


        
2条回答
  •  被撕碎了的回忆
    2020-12-06 20:17

    You have to convert the right side of the range to an integer type, like Int or UInt:

    for i in 0 ..< Int(2 + self.frame.size.width / (movingGroundTexture.size().width)) {
        ...
    }
    

提交回复
热议问题