私はNSManagedObject
オブジェクトを持っている:私はこれらの二つの間の時間間隔を必要とするので、私が実装2つの `NSDate`オブジェクトを持つ` timeIntervalSince() `に` as Date 'が必要ですか?
@NSManaged public var timestamp: NSDate
:
let interval = next.timestamp.timeIntervalSince(current.timestamp)
はなぜ次のエラーで、この結果のでしょうか?
'NSDate' is not implicitly convertible to 'Date'; did you mean to use
'as' to explicitly convert?
next
とcurrent
両方がタイプNSDate
のものであり、timeIntervalSince()
がNSDate
方法ですので、私は驚いています。これは、簡単にエラーに提案を以下で固定だが、私はここで起こっかを理解したいと思い
:
let interval = next.timestamp.timeIntervalSince(current.timestamp as Date)
場合、それは重要、これはスウィフト3.0です。