Reputation: 80
So I have a function that when called, needs to return a CGFloat
value. However, Xcode responds with an error saying: "CGFloat is not convertible to ()". I have looked around the web, but none of the conversions seem to be working for me.
Here is my function
func update() {
point2.y += 1.39
return point2.y //<<<LINE OF ERROR<<<//
}
Upvotes: 0
Views: 61
Reputation: 12367
Your function does not specify a return type.
In Swift, you denote this with arrow (->
) notation.
Try
func update() -> CGFloat {
point2.y += 1.39
return point2.y
}
"CGFloat is not convertible to ()" means that your method returns something of type CGFloat, when a return type of Void (or ()
) is expected.
Upvotes: 1