Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add a predicate for finding the documents
- NSString* filePattern = [NSString stringWithFormat:@"*.%@", @"*"];
- self.metadataQuery = [[NSMetadataQuery alloc] init];
- // Before starting to query, it is required to set the search scope.
- arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
- // It is also required to set a search predicate.
- [self.metadataQuery setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE %@", NSMetadataItemFSNameKey, filePattern]];
- // Listen for the second phase live-updating
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(queryDidReceiveNotification:) name:NSMetadataQueryDidUpdateNotification object:nil];
- // Listen for the first phase gathering
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(queryIsDoneGathering:) name:NSMetadataQueryDidFinishGatheringNotification
- object:nil];
- [self.metadataQuery startQuery];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement