Questions tagged [nsmetadataquery]

The NSMetadataQuery class encapsulates the functionality provided by the MDQuery opaque type for querying the Spotlight metadata.

The NSMetadataQuery class encapsulates the functionality provided by the MDQuery opaque type for querying the Spotlight metadata.

NSMetadataQuery objects provide metadata query results in several ways:

As individual attribute values for requested attributes. As value lists that contain the distinct values for given attributes in the query results. A result array proxy, containing all the query results. This is suitable for use with Cocoa bindings. As a hierarchical collection of results, grouping together items with the same values for specified grouping attributes. This is also suitable for use with Cocoa bindings. Queries have two phases: the initial gathering phase that collects all currently matching results and a second live-update phase.

By default the receiver has no limitation on its search scope. Use setSearchScopes: to customize.

By default, notification of updated results occurs at 1.0 seconds. Use setNotificationBatchingInterval: to customize.

You must set a predicate with the setPredicate: method before starting a query.

Reference: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMetadataQuery_Class/Reference/Reference.html

74 questions
0
votes
1 answer

Wait for iCloud upload to be complete?

I am currently using code similar to the following to upload to my iCloud container: NSData * data = ...; NSURL * documentsURL = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier: @"com.somecontainer.id"]…
Kyle
  • 17,317
  • 32
  • 140
  • 246
0
votes
2 answers

NSMetaDataQuery, set the setSearchScope paths to be recursive?

In Objective-C, I am setting up an NSMetaDataQuery and setting the setSearchScope: for the query to search a specific users Documents folder. The search works but doesn't recurse down the directory tree, only searching in the Documents folder. I've…
Wilersh
  • 85
  • 1
  • 5
0
votes
1 answer

How to filter an NSArray of file urls by Spotlight File Metadata Attributes / NSMetadataQuery?

The NSMetadataQuery class seems to be how Finder/Spotlight searches for files via their metadata. NSMetadataQuery class provided by the Foundation framework. Queries can be run in two modes: asynchronous, and asynchronous with live updates. The…
pkamb
  • 33,281
  • 23
  • 160
  • 191
0
votes
2 answers

NSMetadataQueryDidUpdateNotification, can't get this to work. Code Snippet included

I can't get the NSMetadataQueryDidUpdateNotification to work. Been stuck at it for days. Is there something abnormal in the code below. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0ul), ^{ NSString*…
0
votes
1 answer

metadataquery deallocation before stopquery

I'm using NSMetadataQuery to obtain a list of files in the iCloud ubiquity Documents directory in order to populate a tableview. The code seems to be working, but I get an error stating that the query is being deallocated without first calling…
JohnSF
  • 3,736
  • 3
  • 36
  • 72
0
votes
2 answers

iCloud Drive documents not included in NSMetadataQuery results

I have a basic iOS 8 app that lists the user's documents in the app's iCloud container and also in iCloud Drive. My problem is that documents that are directly in iCloud Drive (Finder → Go → iCloud Drive) are not included as results of the metadata…
Mark
  • 6,647
  • 1
  • 45
  • 88
0
votes
1 answer

NSMetadataQuery’s update notification interferes with (run loop?)

I emailed an Apple engineer last week about a problem with my NSMetadataQuery. Here’s the email: Hi, I'm writing a document-based app or iOS and my method for renaming (moving the document to a new location) seems to conflict with the running…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
0
votes
1 answer

NSMetadataQuery not working

I am trying to use iCloud in my app. In the simulator, I notice that it takes a short amount of time after launch for new files in iCloud to be added to the ubiquity container. So to refresh my UI to reflect these changes, I set up an…
Macro206
  • 2,143
  • 3
  • 19
  • 25
0
votes
1 answer

How to correctly fill a UITableView with asynchronous content that needs to be sorted

I have a bunch of files in various sizes (>100) stored in iCloud. I have a NSMetadataQuery that returns these files. They are reported to my app from the NSMetadataQuery object in random order. I open them and extract a couple of strings which then…
Joseph
  • 9,171
  • 8
  • 41
  • 67
0
votes
1 answer

removeItem in iCloud instantly

Im using NSFM's method removeItemAtURL to remove some item in iCloud, though right after that i run a NSMetaDataQuery and it can still see this item for like 3 seconds. Is there a way to fix this? Im trying to upload an item to iCloud, and if file…
t0a0
  • 668
  • 1
  • 9
  • 18
0
votes
1 answer

NSMetadataQuery won't find files in Lion, Mountain Lion, or Mavericks

If you create a vanilla project and make this the implementation of your app delegate: @interface TESTAppDelegate () @property (nonatomic, strong) NSMetadataQuery *query; @end @implementation TESTAppDelegate -…
SG1
  • 2,871
  • 1
  • 29
  • 41
0
votes
1 answer

NSMetadataQuery says there are no documents, despite data successfully syncing?

I'm trying to get my OS X app to update automatically from changes to an iCloud document, and I'm having a really hard time getting the notification to work. Specifically, I was given some code that should list out all the results of my…
Nerrolken
  • 1,975
  • 3
  • 24
  • 53
0
votes
2 answers

NSPredicate(s) for NSMetadataQuery to match kMDItemAccessedDates (array) containing a target date?

UPDATE: I found an answer though there may still be a better way - see the answer added below. a spotlight importer imports metadata that is an array of dates in which an item was accessed. Looks like this: kMDItemAccessedDates = ( …
Dad
  • 6,388
  • 2
  • 28
  • 34
0
votes
1 answer

Search scope of NSMetadataQuery

Is there any way of excluding the /Users/username/Library (which is hidden by default) from the search scope of NSMetadataQuery.
Suhaiyl
  • 1,071
  • 9
  • 17
1 2 3 4
5