Mic*_*ele 1 floating-point objective-c init
我构建了一个类并创建了一个初始化所有变量的方法.
在.h
-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_;
Run Code Online (Sandbox Code Playgroud)
并在.m
-(void) initWithX:(float *)x_ andY:(float *)y_ andWidth:(float *)width_{
[super init];
x = x_; ***
y = y_; ***
width = width_; ***
}
Run Code Online (Sandbox Code Playgroud)
带*的行给我错误"分配中的不兼容类型",但我不明白:我在.h中给出3个浮点数!
谢谢你们
通过删除以下内容按值传递您的浮点数*:
- (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_;
}
Run Code Online (Sandbox Code Playgroud)
否则,该方法要求指向 floats(float *),而不是它们的实际原始值.
| 归档时间: |
|
| 查看次数: |
2862 次 |
| 最近记录: |