开发者

What silly noob mistake am I making here?

开发者 https://www.devze.com 2023-01-06 01:09 出处:网络
I have a method: - (CGPoint) calculateVectorBetweenThisPoint:(CGPoint)firstPoint andThisPoint:(CGPoint)secondPoint

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消