Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // Add a predicate for finding the documents
  2. NSString* filePattern = [NSString stringWithFormat:@"*.%@", @"*"];
  3.  
  4. self.metadataQuery = [[NSMetadataQuery alloc] init];
  5.  
  6. // Before starting to query, it is required to set the search scope.
  7. arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
  8.  
  9. // It is also required to set a search predicate.
  10. [self.metadataQuery setPredicate:[NSPredicate predicateWithFormat:@"%K LIKE %@", NSMetadataItemFSNameKey, filePattern]];
  11.  
  12. // Listen for the second phase live-updating
  13. [[NSNotificationCenter defaultCenter] addObserver:self
  14. selector:@selector(queryDidReceiveNotification:) name:NSMetadataQueryDidUpdateNotification object:nil];
  15.  
  16. // Listen for the first phase gathering
  17. [[NSNotificationCenter defaultCenter] addObserver:self
  18. selector:@selector(queryIsDoneGathering:) name:NSMetadataQueryDidFinishGatheringNotification
  19. object:nil];
  20.  
  21. [self.metadataQuery startQuery];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement