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
1
vote
1 answer

cannot call NSMetadataQueryDidUpdateNotification

I want to track percentage of my uploaded file to icloud using NSMetadataQuery, but It didn't work. This is my code : dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { NSFileCoordinator* fileCoordinator =…
Faiz
  • 91
  • 1
  • 5
1
vote
1 answer

iCloud - NSMetadataQuery not sorting with NSMetadataItemFSCreationDateKey

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…
Nikunj
  • 987
  • 11
  • 25
1
vote
1 answer

NSPredicate predicateWithFormat for NSMetaDataQuery in iOS

I need to append my custom string into NSPredicate. So I wrote following codes. self.query = [[NSMetadataQuery alloc] init]; [self.query setSearchScopes: [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]]; NSPredicate *pred =…
Fire Fist
  • 7,032
  • 12
  • 63
  • 109
1
vote
2 answers

Setting up NSMetadataQueryDidUpdateNotification for a simple response

I'm trying to get up and running with an NSMetadataQueryDidUpdateNotification on an OS X app, to alert me when a file in my iCloud ubiquity container is updated. I've been doing a lot of research (including reading other Stack answers like this,…
Nerrolken
  • 1,975
  • 3
  • 24
  • 53
1
vote
0 answers

NSMetadataQuery returns results outside of searchScopes

I'm working with a joint Mac/iOS app that syncs documents and data via iCloud to one another. In order to detect when data changes, I use NSMetadataQuery to observe the relevant iCloud folder. The apps also use another purely local data storage…
Andrew
  • 2,690
  • 23
  • 27
1
vote
0 answers

iCloud NSMetadata query results empty

Hi friend i have got NSMetaDataQuery results are blank and i analyzed this link. i am confused.Please help me, here i add my source code of meta query - (NSMetadataQuery *)documentQuery { NSMetadataQuery * query = [[NSMetadataQuery alloc]…
Vijay
  • 579
  • 1
  • 11
  • 22
1
vote
1 answer

How to group the results from NSMetadataQuery

I am performing a query (NSMetadataQuery) on the local data as spotlight performs and sorting the results as per modification date of the files, everything is working fine till this point. BUT i am not able to understand how can we group the…
Suhaiyl
  • 1,071
  • 9
  • 17
1
vote
0 answers

NSMetadataItemFSCreationDateKey is always null for my iCloud NSMetadataItems

In doing an NSMetadataQuery, I'm getting results back and I'm getting the file paths but NSMetadataItemFSCreationDateKey is always null. For example: for (NSMetadataItem * result in sortedResults) { NSLog(@"Going through results"); …
tharris
  • 2,192
  • 2
  • 13
  • 14
1
vote
1 answer

iCloud Error "The operation couldn't be completed. (LibrarianErrorDoman error 10 - Unable to configure the collection.)"

i want to migrate my existing app to iCloud. in my attempt to learn what to do, i have tried a sample app that has worked as described in the demo (as seen in lecture 17 of the iTunes stanford university course). can someone who has had this problem…
john.k.doe
  • 7,533
  • 2
  • 37
  • 64
1
vote
1 answer

Verify document existence on iCloud container

I'm using NSMetadataQuery to detect if a document exists on my application iCloud container even if the file has not been downloaded locally. Can NSFileCoordinator with an NSFilePresenter do the same ? Verifying that the file exists even though it…
the Reverend
  • 12,305
  • 10
  • 66
  • 121
1
vote
2 answers

Why is checking [NSMetadataQuery class] crashing on iOS 4.2.1?

I'm attempting to use this approach, described by Marco Arment, for checking if a class exists before using it. With the correct settings, classes are automatically weak-linked when it's appropriate. As Marco describes, "you can safely subclass or…
robotspacer
  • 2,732
  • 2
  • 28
  • 50
0
votes
2 answers

iOS: "Symbol not found" error on some iOS4 devices, but not all

I'm getting the following message in my users' crash logs: Dyld Error Message: Symbol not found: _OBJC_CLASS_$_NSMetadataQuery So I understand the solution is that I should be making the Foundation framework "Optional". But what's bizzare to me…
Z S
  • 7,039
  • 12
  • 53
  • 105
0
votes
0 answers

Why does this code cause NSMetadataQuery to crash?

I got an extremely simple Xcode project. It has a single file app delegate with the following content @interface TestController : NSObject @property (assign) IBOutlet NSWindow *window; @property…
Tony
  • 36,591
  • 10
  • 48
  • 83
0
votes
1 answer

How can I use spotlight search from swift in the same way like I do it in terminal? NSMetadataQuery?

lets imagine that I need to know which apps was run in 1 week period. Query for terminal looks like: mdfind '(InRange(kMDItemFSContentChangeDate,$time.today(-7d), $time.today(+1d)) && ((kMDItemContentTypeTree=com.apple.application) &&…
Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101
0
votes
1 answer

How to limit the number of results returned from NSMetadataQuery?

Is there a way to limit the maximum number of file search results that are returned from an NSMetadataQuery query on macOS? Currently, if I enter 1-2 characters as a query string, it takes over 5 seconds to receive the initial set of results, and…
glocore
  • 1,727
  • 1
  • 14
  • 24