I have been researching, but I couldnt find exact solution for my problem. I have been trying to get 1 hour ago from a date. How can I achieve this in swift?
for Swift 2:
extension NSDate { func after(value: Int, calendarUnit:NSCalendarUnit) -> NSDate { return calendar.dateByAddingUnit(calendarUnit, value: value, toDate: self, options: [])! } }
how to use:
let lastHour = NSDate().after(-1, calendarUnit: .Hour)