1

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"

Leighton
  • 6,559
  • 7
  • 21
  • 28

1 Answers1

2

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.

GonzoCoder
  • 259
  • 2
  • 6