I am getting list of files in array from iCloud, I want that files in sorting order either with NSMetadataItemFSCreationDateKey
or NSMetadataItemFSContentChangeDateKey
. But it's not returning as per given NSSortDescriptor
.
Here is my code, please suggest me if anything is missing or i need to add anything.
-(void)getiCloudData
{
[appdel.metadataQuery setSearchScopes:[NSArray arrayWithObjects: NSMetadataQueryUbiquitousDocumentsScope,NSMetadataQueryUbiquitousDataScope ,nil]];
[appdel.metadataQuery setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE '*'", NSMetadataItemFSNameKey]];
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:NSMetadataItemFSCreationDateKey
ascending:FALSE] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObjects:
sortDescriptor,
nil];
[appdel.metadataQuery setSortDescriptors:sortDescriptors];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(queryDidReceiveNotification:)
name:NSMetadataQueryDidFinishGatheringNotification
object:appdel.metadataQuery];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updatequeryDidReceiveNotification:)
name:NSMetadataQueryDidUpdateNotification
object:appdel.metadataQuery];
[appdel.metadataQuery enableUpdates];
[appdel.metadataQuery startQuery];
}
Thanks.