2
我有一个方法:我在这里做了什么愚蠢的noob错误?
- (CGPoint) calculateVectorBetweenThisPoint:(CGPoint)firstPoint andThisPoint:(CGPoint)secondPoint
{
float xDif = firstPoint.x - secondPoint.x;
float yDif = firstPoint.y - secondPoint.y;
return CGPointMake(xDif, yDif);
}
我尝试如下调用它:
- (float) angleBetweenThisPoint:(CGPoint)firstPoint andThisPoint:(CGPoint)secondPoint
{
// COMPILE ERROR HERE: Invalid Initializer
CGPoint vector = [self calculateVectorBetweenThisPoint:firstPoint andThisPoint:secondPoint];
return atan2(vector.x, vector.y);
}
但我得到一个编译erorr,我尝试使用方法:“无效的初始化程序”。
我在做什么错?
正确。 'calculateVectorBetweenThisPoint:andThisPoint:'必须在头文件中定义,或者放置在实现文件中的'angleBetweenThisPoint:andThisPoint:'之前。 – 2010-07-06 11:24:01
+1(即使你的意思是声明,没有定义) – 2010-07-06 11:38:10
哎呀,你是对的。编辑! – Wevah 2010-07-06 11:41:57