看起来正确的方法是在创建查询时设置查询的排序描述符。这些方面的东西:
NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
[query setSearchScopes:[NSArray arrayWithObject:
NSMetadataQueryUbiquitousDocumentsScope]];
NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K ENDSWITH '.bin'",
NSMetadataItemFSNameKey];
[query setPredicate:pred];
NSSortDescriptor *sortDescriptor =
[[[NSSortDescriptor alloc] initWithKey:NSMetadataItemFSContentChangeDateKey
ascending:FALSE] autorelease]; //means recent first
NSArray *sortDescriptors = [NSArray arrayWithObjects:
sortDescriptor,
nil];
[query setSortDescriptors:sortDescriptors];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(queryDidFinishGathering:)
name:NSMetadataQueryDidFinishGatheringNotification
object:query];
[query startQuery];