Josh Schlabach Josh Schlabach -5 years ago 184
Swift Question

Binary operator '..<' cannot be applied to two 'Int' operands [Swift]

Okay so I was programming in my Xcode project and suddenly I got a warning that this:

for var i:CGFloat = 0; i<3; i++

will be removed in Swift 3. It gave me an option to "fix" the code to Swift 3 syntax and switched it to this:

for i:CGFloat in 0 ..< 3 {

Now my code will not run and the error it gets "Binary operator '..<' cannot be applied to two '
' operands.

Help would be nice!

Answer Source
for i in 0..<3 {
    let someFloat = CGFloat(i) // if you need a CGFloat

Check your spacing, remove the CGFloat type from the loop declaration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download