Mahmud Ahmad
Mahmud Ahmad

Reputation: 171

Swift conversions, CGFloat to Integer

How do you convert a @IValue CGFloat to an Int?

I keep getting a cannot convert @IValue CGFloat to Integer with the following:

@IBOutlet var userObject : UIImageView


func returnYPosition(yPosition: Integer) -> Integer {
    return userObject.center.y
}

Upvotes: 3

Views: 6240

Answers (1)

Nate Cook
Nate Cook

Reputation: 93276

You need to pass Int types back and forth, and then just cast:

func returnYPosition(yPosition: Int) -> Int {
    return Int(userObject.center.y)
}

Upvotes: 5

Related Questions