Im trying to return a CGPoint
from a CGPoint extension
.
I have this extension
:
extension CGPoint {
func Multiply(factor:Int) {
return self.x*factor, self.y*factor
}
}
Now, no matter how I change the return line
I get a different error.
Ive tried to put {},[],()
around it, Ive tried {1,2},[1,2],(1,2)
And CGPointMake()
isnt allowed.
And like I could in Obj-C {.x = 1, .y = 2}
Nothing seems to work and I get a different error for each.
You forgot to declare the return type (CGPoint):
extension CGPoint {
func Multiply(factor:CGFloat) -> CGPoint {
return CGPoint(x: self.x*factor, y:self.y*factor)
}
}
That should compile.