Relative date for NSDate

NSDate does not have relative date method, so you will need to use NSCalendar to compare with current time, get the NSDateComponents return, and check those date selectors one by one.

Instead of checking them manually, I create a NSArray that holds the name of those selectors, and use NSInvocation to find out first non-zero result, and return it as relative date.

Where to download

The source code is available on github.

  1. wisesabre reblogged this from digdog
  2. digdog posted this