2015-08-15 25 views
0

初始化NSTimeInterval我想使用此代碼初始化一個NSTimeInterval:不能與timeIntervalSince1970

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

但它不斷拋出一個錯誤:

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

如何解決這個問題?

+0

閱讀'NSTimeInterval'文件這是一個雙重價值的tyoedef! –

回答

6

NSTimerInterval是原始類型,而不是對象類型。不需要指針,就像錯誤狀態一樣。你想要:

NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970];