看起來正確的做法是在創建查詢時設置查詢的排序描述符。沿着這些線:
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];
你有沒有找到這方面的解決方案? – rizzz86