2011-01-31 68 views
1

我构建了一个类并创建了初始化所有变量的方法。在.H错误:赋值中的不兼容类型

-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_; 

和.M

-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_{ 
    [super init]; 
    x = x_; *** 
    y = y_; *** 
    width = width_; *** 
} 

线,*给我 “在分配类型不兼容” 的错误,但我不明白:我给在.h中告诉的3个浮动

谢谢大家

回答

5

通过移除*通过值传递的花车:

- (void)initWithX:(float)x_ andY:(float)y_ andWidth:(float)width_; 

- (void)initWithX:(float)x_ andY:(float)y_ andWidth:(float)width_ { 
    [super init]; 
    x = x_; 
    y = y_; 
    width = width_; 
} 

。否则,方法是要求指针到彩车(float *),而不是他们的实际基本

1

您正在询问浮点指针,并可能将它们指定给浮点变量。取出方法声明中的星号。