Objective c 指向接口';NSDate&x27;,在非易碎ABI中,其尺寸不是恒定的

Objective c 指向接口';NSDate&x27;,在非易碎ABI中,其尺寸不是恒定的,objective-c,xcode,Objective C,Xcode,在下一个obj-c代码中出现问题错误 if (fabs(originalLocation.timestamp - ((CLLocation *)[lastLocations objectAtIndex:i]).timestamp) > constAverageLocationTimeout) { //do } xCode发送错误: error: Semantic Issue: Arithmetic on pointer to interface 'NSDate', whic

在下一个obj-c代码中出现问题错误

if (fabs(originalLocation.timestamp - ((CLLocation *)[lastLocations objectAtIndex:i]).timestamp) > constAverageLocationTimeout) 
{ 
    //do 
}
xCode发送错误:

error: Semantic Issue: Arithmetic on pointer to interface 'NSDate', which is not a constant size in non-fragile ABI
你有什么想法吗

如果稍微分解一下程序(以及编译器错误的位置),它会更有意义。也许是这样的:

NSDate * orginalDate = originalLocation.timestamp;
CLLocation * lastLocation = [lastLocations objectAtIndex:i];
NSDate * lastDate = lastLocation.timestamp;

NSTimeInterval originalTime = [originalDate timeIntervalSinceReferenceDate];
NSTimeInterval lastTime = [lastDate timeIntervalSinceReferenceDate];
NSTimeInterval elapsed = fabs(originalTime - lastTime);

if (elapsed > constAverageLocationTimeout) {
  /* do */
}

具体来说,
timestamp
是类型为
NSDate
的属性,而不是像NSTimeInterval这样的标量数。

是的,它确实有帮助。非常感谢你。