Extracting time from NSDate in Swift

Leighton

Right now I have an NSDate set to be stored in NSUserDefaults. When I go to retrieve that date I want to extract and format the time. Can anyone tell me how to do this in Swift?

I have:

punchTimes.setObject(NSDate(), forKey: "punchInTime")
punchTimes.synchronize()

set to store date, and would like to retrieve the NSDate time for "punchInTime"

GonzoCoder

Retrieve the NSDate object from NSUserDefaults by calling punchTimes.objectForKey("punchInTime")

Then use NSDateFormatter class to create a String formatted the way you want it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related