开发者

Incompatible type in assignment

Getting error: Incompatible type in assignment at fValue = ..., see the code

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

here is the method

-(float) easeOutBo开发者_StackOverflow社区unce:(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;  
    }  
}


When the compiler encounters an unknown method (i.e. a method that is being used but hasn't been declared in an @interface, or previously defined in an @implementation), the compiler will issue a warning, and assume that the method returns id, which is a pointer type, which you can't assign to a float type.

Make sure that your @interface has the declaration for your easeOutBounce:andB:andC:andD: method, or, at the very least, make sure that this method is defined above the code that uses it.

For example:

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜