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
2
votes
1 answer

How do I filter NSMetadataQuery

I am trying to create a NSMetadataQuery with a predicate. At a certain point I may want to gather all videos iCloud may have at another point all images. I don't want anything else, just search for videos or search for images. Not both at the same…
Duck
  • 34,902
  • 47
  • 248
  • 470
2
votes
0 answers

Spotlight API (NSMetadataQuery ) not returning results

I'm trying to work with the NSMetadataQuery in a C++\Qt project and I got it to compile and run but I only get the NSMetadataQueryDidStartGatheringNotification. I've seen many questions regarding this issue but none of them worked for me. The…
ManicQin
  • 159
  • 1
  • 8
2
votes
0 answers

Implementing Spotlight feature using NSMetaDataQuery and NStableView Data Source Method

I have implemented spotlight feature in my project using NSMetadataQuery. On receiving NSMetadataQueryDidFinishGatheringNotification Notification I am calling reloadData method of tableView method after formatting the NSMetadataItem of…
Akhil Shrivastav
  • 427
  • 3
  • 13
2
votes
2 answers

How do I create a NSMetaDataQuery and get results on a background thread?

By default NSMetaDataQuery results notifications are received on the main thread. It seems you have to call query.startQuery on the main thread, but you can use [query.setOperationQueue:] to set the queue to which results notifications will be…
Duncan Groenewald
  • 8,496
  • 6
  • 41
  • 76
2
votes
1 answer

NSMetadataQuery does not find documents after moving them to iCloud

In my Mac app I have an NSMetadataQuery to watch the app's iCloud directory. When the user decides to enable iCloud from within the app I do the following in this order: Call [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] to…
Mark
  • 6,647
  • 1
  • 45
  • 88
2
votes
0 answers

UIManagedDocument, iCloud and document types

I have an app that uses a UIManagedDocument (i.e., Core Data) document format. To keep life interesting I am trying to get it to work with iCloud. I have managed to get to the point where I can get one of the following two options: It works but in…
Stephen Darlington
  • 51,577
  • 12
  • 107
  • 152
2
votes
2 answers

NSMetadataQuery enableUpdates

I am having trouble understanding how updates work with an NSMetadataQuery. I am trying to determine whether a file has finished downloading from iCloud. My initial query tells me clearly enough the the file is not downloaded and I can start the…
2
votes
1 answer

Problems handling NSMetadataQueryDidUpdateNotification non-UIDocument based iCloud files

I've already got headaches when trying to solve this: in my current app I'm using iCloud to store my documents - but I can't use UIDocument based storage for the data. So my approach was to follow WWDC 2012 article 237 (advanced iCloud document…
konran
  • 588
  • 7
  • 20
2
votes
2 answers

Search string predicate

I am trying to create a search query using NSMetaDataQuery and deploying a predicate as below : NSString * format = @"kMDItemDisplayName like[cd] %@"; NSPredicate * compPred = [NSPredicate predicateWithFormat:format,[NSString…
Suhaiyl
  • 1,071
  • 9
  • 17
1
vote
1 answer

iCloud: Getting an array of txt files present in the cloud on OS X

I am trying to get an array of txt files in my app's iCloud folder using a NSMetadataQuery as recommended by Apple: NSMetadataQuery *query = [[NSMetadataQuery alloc] init]; [query setSearchScopes:[NSArray…
Daniel
  • 1,473
  • 3
  • 33
  • 63
1
vote
1 answer

Not getting NSMetaDataQuery update Notification

I have the following code: // Main thread NotificationCenter.default.addObserver( self, selector:#selector(queryDidFinish), name:NSNotification.Name.NSMetadataQueryDidFinishGathering, object:nil) NotificationCenter.default.addObserver(…
Sandy
  • 23
  • 3
1
vote
1 answer

Do I need NSMetadataQueryDidFinishGathering, if I watch every NSMetadataQueryGatheringProgress?

NSMetadataQuery posts NSMetadataQueryGatheringProgress as the query runs and then NSMetadataQueryDidFinishGathering, when it's done. I'm receiving both notifications, and they work fine. I notice, though, that when I get…
Ssswift
  • 916
  • 10
  • 20
1
vote
1 answer

NSMetadataQuery returns nothing

Using xcode 8 running on iOS 10. Trying to put together a super simple NSMetadataQuery. Waisted almost a day on this now. Managed to get this to do a query, but it doesn't return any documents from My iCloud, none. class ViewController:…
user3069232
  • 8,587
  • 7
  • 46
  • 87
1
vote
1 answer

NSMetadataQuery doesn't return any data

I try to list all of my file on my Mac for an app that I made. I use NSMetadataQuery but it's not working. Here is the code: import Cocoa class ViewController: NSViewController { let metadataQuery = NSMetadataQuery() @IBOutlet weak var…
N..
  • 125
  • 6
1
vote
1 answer

NSMetaDataQuery: Not receiving notification for update or gathering finished

I am trying out some code to use NSMetaDataQuery to get an application path based on bundle Identifier. I was following hte sample code found in the apple dev site: Static Spotlight search implementation. I wrote the following files for…
sajas
  • 1,599
  • 1
  • 17
  • 39