Skip to content

Instantly share code, notes, and snippets.

@niw
Created January 17, 2019 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niw/e053b323a7ab61500bd52fc5439e4f69 to your computer and use it in GitHub Desktop.
Save niw/e053b323a7ab61500bd52fc5439e4f69 to your computer and use it in GitHub Desktop.
`ascending` and `descending` are confusing.
@import Foundation;
int main()
{
NSDate * const a = [[NSDate alloc] initWithTimeIntervalSince1970:0];
NSDate * const b = [[NSDate alloc] initWithTimeIntervalSince1970:1];
NSLog(@"%d", (int)[a compare:b]); // -1 = NSOrderedAscending
NSLog(@"%d", (int)[a compare:a]); // 0 = NSOrderedSame
NSLog(@"%d", (int)[b compare:a]); // 1 = NSOrderedDescending
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment