这导致我的应用出现问题。此错误发生在这一行 modff(floatIndex, &intIndex);
我需要做什么来解决这个问题?
编辑:这是因为 &intIndex
- (BOOL)isFloatIndexBetween:(CGFloat)floatIndex {
CGFloat intIndex, restIndex;
restIndex = modff(floatIndex, &intIndex);
BOOL isBetween = fabsf(restIndex - 0.5f) < EPSILON;
return isBetween;
}
最佳答案
我记得 CGFloat 在 32 位设备上定义为 float,在 64 位设备上定义为 double。因此,您不想在调用 modff() 时使用 CGFloat。相反,使用特定类型声明您的参数,并使用转换。
类似这样的事情(在这种情况下,我使用 modf 和所有浮点变量。
- (BOOL)isFloatIndexBetween:(CGFloat)floatIndex
{
float restIndex;
float first, second;
first = (float) floatIndex;
restIndex = modf(first, &second);
BOOL isBetween = fabsf(restIndex - 0.5f) < EPSILON;
return isBetween;
}
关于iOS 警告消息 : Incompatible pointer types passing 'CGFloat *' (aka 'double *' ) to parameter of type 'float *' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28289712/