无法用 timeIntervalSince1970 初始化 NSTimeInterval

cant initialize NSTimeInterval with timeIntervalSince1970

我正在尝试使用以下代码初始化 NSTimeInterval:

NSTimeInterval *timeStamp = [[NSDate date] timeIntervalSince1970];

但它一直报错:

Initializing 'NSTimeInterval *' (aka 'double *') with an expression of incompatible type 'NSTimeInterval' (aka 'double')

我该如何解决这个问题?

NSTimerInterval 是原始类型,不是对象类型。不需要指针,就像错误状态一样。你想要:

NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];