I tried to use MDQuerySetSortComparatorBlock method inside the MDQuery framework to sort the query result list. However, the block passed as a parameter to the method doesn't get called at all. Below is a piece of code that I'm using to make a query request. Any help is appreciated.
queryString = [NSString stringWithFormat:@"kMDItemDisplayName == \'*a*\'cd"];
CFStringRef query = (__bridge CFStringRef)(queryString);
queryReference = MDQueryCreate(NULL, query, (__bridge CFArrayRef)([NSArray arrayWithObjects:(id)kMDItemDisplayName, nil]), NULL);
MDQuerySetSortComparatorBlock(queryReference, ^CFComparisonResult(const CFTypeRef *attrs1, const CFTypeRef *attrs2) {
NSLog(@"Block called");
return kCFCompareLessThan;
});
MDQuerySetSearchScope(queryReference, (__bridge CFArrayRef)([NSArray arrayWithObjects:(id)kMDQueryScopeComputer, nil]), 0);
MDQueryExecute(queryReference, kMDQueryWantsUpdates);