I have a
myDate = 24/05/2011
According to Apple documentation of
Returns an NSComparisonResult value that indicates the temporal ordering of the receiver and another given date.
- (NSComparisonResult)compare:(NSDate *)anotherDate
The date with which to compare the receiver. This value must not be nil. If the value is nil, the behavior is undefined and may change in future versions of Mac OS X.
The receiver and anotherDate are exactly equal to each other,
The receiver is later in time than anotherDate,
The receiver is earlier in time than anotherDate,
In other words:
if ([date1 compare:date2] == NSOrderedSame) ...
Note that it might be easier in your particular case to read and write this :
if ([date2 isEqualToDate:date2]) ...