What silly noob mistake am I making here?
I have a method:
- (CGPoint) calculateVectorBetweenThisPoint:(CGPoint)firstPoint andThisPoint:(CGPoint)secondPoint
{
float xDif = firstPoint.x - secondPoint.x;
float yDif = firstPoint.y - secondPoint.y;
return CGPointMake(xDif, yDif);
}
And I try to invoke it as follows:
- (float) angleBetweenThisPoint:(CGPoint)firstPoint andThisPoint:(CGPoint)secondPoint
{
// COMPILE ERROR HERE: Invalid Initializer
CGPoint vector = [self calculateVectorBetweenThisPoint:firstPoint andThisPoint:secondPoint];
return atan2(vector.x, ve开发者_JS百科ctor.y);
}
But I get a compilation erorr where I try to use the method: "Invalid Initializer".
What am I doing wrong?
Is calculateVectorBetweenThisPoint:andThisPoint:
declared before you use it? If it's not, the compiler will assume a return type of id
which is definitely an invalid thing to put into a CGPoint
.
精彩评论