You can use the system method of the NSDate class to compare with the current time.
- (NSTimeInterval)timeIntervalSinceNow
The return value is the interval between the receiver and the current date and time. If the receiver is earlier than the current date and time, the return value is negative.
So the correct code will be
- (BOOL) hasExpired:(NSDate*)myDate { return [myDate timeIntervalSinceNow] < 0.f; }
Or, if you want to compare 2 dates, use
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate
source share