分配中的类型不兼容

时间:2010-06-03 07:20:14

标签: objective-c iphone

获取错误:fValue = ...时分配的类型不兼容,请参阅代码

static float t = 0;        
float d = .5;        
static float fValue = 0;        
fValue = [self easeOutBounce:t andB:0 andC:30 andD:d]; 

这是方法

-(float) easeOutBounce:(float)t andB:(float)b andC:(float)c andD:(float)d {
    if ((t/d) < (1/2.75)) {  
        return c*(7.5625*t*t) + b;  
    } else if (t < (2/2.75)) {  
        return c*(7.5625*(t-(1.5/2.75))*t + .75) + b;  
    } else if (t < (2.5/2.75)) {  
        return c*(7.5625*(t-(2.25/2.75))*t + .9375) + b;  
    } else {  
        return c*(7.5625*(t-(2.625/2.75))*t + .984375) + b;  
    }  
}

1 个答案:

答案 0 :(得分:1)

当编译器遇到未知方法(即正在使用但尚未在@interface中声明或先前在@implementation中定义的方法)时,编译器将发出警告,并假设该方法返回id,这是一种指针类型,您无法将其分配给float类型。

确保您的@interface包含easeOutBounce:andB:andC:andD:方法的声明,或者至少确保此方法已定义以上使用的代码它

例如:

@interface MyClass : NSObject
{
    float myVar;
}
-(float) easeOutBounce:(float)t andB:(float)b andC:(float)c andD:(float)d;
@end
相关问题