I use the following function to check if a message has expired –
- (BOOL) hasExpired:(NSDate*)myDate
{
if(myDate == nil)
{
return false;
}
NSDate *now = [NSDate date];
return !([now compare:myDate] == NSOrderedAscending);
}
This works fine if I am comparing two different dates. However, it returns false if the message has expired earlier in the day today. Any ideas on how I might fix it?
(Adding my comment as an answer:)
This should not happen, also 1 second difference between
NSDateinstances is enough. Add anNSLog()with both dates there to see whether they are different indeed.