Search code examples
iphoneiosnsdate

Find out if an NSDate is today, yesterday, tomorrow


With the iOS SDK I need to find an easy and secure way to see if an NSDate is today, yesterday, tomorrow. What I'm looking for is something like this in pseudo code:

NSDate *myDate = someDate;
if ([myDate isTomorrow]) {
    NSLog("Tomorrow"); 
}

How would you solve it?


Solution

  • Check our Erica Sadun's great NSDate extension class: http://github.com/erica/NSDate-Extensions

    There are lots of date comparisons, among them exactly what you need :)