Instance Method

compare:

Indicates the temporal ordering of the receiver and another given date.

Declaration

- (NSComparisonResult)compare:(NSDate *)other;

Parameters

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 macOS.

Return Value

If:

Discussion

This method detects sub-second differences between dates. If you want to compare dates with a less fine granularity, use timeIntervalSinceDate: to compare the two dates.

See Also

Comparing Dates

- isEqualToDate:

Returns a Boolean value that indicates whether a given object is a date that is exactly equal the receiver.

- earlierDate:

Returns the earlier of the receiver and another given date.

- laterDate:

Returns the later of the receiver and another given date.