why aint work let time = [[NSDate date] timeIntervalSince1970];"
- User
why aint work
let time = [[NSDate date] timeIntervalSince1970];"
- Assistant
It looks like you're writing a line of Objective-C code to get the current time as the number of seconds since the "Unix epoch" (January 1, 1970), but your syntax is slightly incorrect. Here's how to correctly write this in Objective-C:
objcNSTimeInterval time = [[NSDate date] timeIntervalSince1970];Make sure you're including this line of code inside a method in your Objective-C implementation (.m) file or a function where you want to use it. Also ensure that you have imported the
Foundationframework at the top of your file, but usually it's already included by default in the precompiled header (e.g., YourProject-Prefix.pch) like this:objc#import <Foundation/Foundation.h>Explanation of your original code issues:
-
letis a keyword from Swift, not Objective-C. In Objective-C, you declare variables using types like , , , etc. For time intervals, you use .
-