Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
}
like image 797
Mahmud Ahmad Avatar asked May 14 '26 23:05

Mahmud Ahmad


1 Answers

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

func returnYPosition(yPosition: Int) -> Int {
    return Int(userObject.center.y)
}
like image 131
Nate Cook Avatar answered May 17 '26 11:05

Nate Cook



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!