Con*_*oob 2 iphone xcode objective-c
我有一个方法:
- (CGPoint) calculateVectorBetweenThisPoint:(CGPoint)firstPoint andThisPoint:(CGPoint)secondPoint
{
float xDif = firstPoint.x - secondPoint.x;
float yDif = firstPoint.y - secondPoint.y;
return CGPointMake(xDif, yDif);
}
Run Code Online (Sandbox Code Playgroud)
我尝试按如下方式调用它:
- (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);
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个编译错误,我尝试使用该方法:"无效的初始化程序".
我究竟做错了什么?
被calculateVectorBetweenThisPoint:andThisPoint:宣布之后再使用?如果不是,编译器将假定一个返回类型,id它绝对是一个无效的东西CGPoint.
| 归档时间: |
|
| 查看次数: |
311 次 |
| 最近记录: |