I have an NSDate object called 'dueDate'. I'm trying to work out how to display if the due date was yesterday or is tomorrow. How would I go about this?
To see if a date is "tomorrow", do something like this.
    NSCalendar *calendar = [NSCalendar currentCalendar];    
    NSDate *currentDate = [NSDate date];
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    // set tomorrow (0: today, -1: yesterday)
    [comps setDay:1];
    NSDate *dateTomorrow = [calendar dateByAddingComponents:comps 
                                                     toDate:currentDate  
                                                    options:0];
    [comps release];
The rest should be fairly obvious.
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With