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

How do I determine if file exists in iCloud folder?

I have an iOS app that stores files in iCloud. When I start up the app I want to determine if a previous device has already uploaded any files. I start the first device and it adds the files to iCloud (I can see them in the Mobile Documents folder…
Austin
  • 4,638
  • 7
  • 41
  • 60
7
votes
2 answers

NSMetaDataQuery never calls back with NSMetadataQueryDidFinishGatheringNotification

For an iCloud plugin I'm writing, I subscribe my iCloud manager class to these iCloud NSMetaDataQuery observers: // Add a predicate for finding the documents NSString* filePattern = [NSString stringWithFormat:@"*.%@", @"*"]; self.metadataQuery =…
CodingBeagle
  • 1,888
  • 2
  • 24
  • 52
7
votes
2 answers

How can I sort an icloud NSMetadataQuery result of UIDocument's by modification date?

I have an iOS application that uses a simple UIDocument model with a single content field for iCloud storage. I retrieve the list of documents to populate a UITableView using an NSMetadataQuery. I want to have new documents appear at the top of this…
Jason N
  • 463
  • 3
  • 10
7
votes
2 answers

Accessing the desktop in a Sandboxed app

I'm building an application that has a feature to open newly taken screenshots. I would like to distribute it using the Mac App Store. Unfortunately, it needs to be sandboxed. To find the new screenshots I run a NSMetaDataQuery. It returns a few…
BrainOverfl0w
  • 257
  • 1
  • 3
  • 13
6
votes
2 answers

NSMetadataQuery ignoring custom file package type

I'm using UIManagedDocuments to manage my files in iCloud. After setting up the NSMetadataQuery like so: iCloudQuery = [[NSMetadataQuery alloc] init]; [iCloudQuery setSearchScopes: [NSArray…
Stuart
  • 36,683
  • 19
  • 101
  • 139
6
votes
1 answer

Getting NSMetadataItem for local files on iOS App Sandbox

I am aware that on iOS you can only use NSMetadataQuery for iCloud files. However, according to Apple's guide, you can still get NSMetadataItem by searching for the file you want manually with FileWrapper: iOS allows metadata searches within iCloud…
HuaTham
  • 7,486
  • 5
  • 31
  • 50
5
votes
4 answers

NSMetadataQuery doesn't finish gathering (no notification)

I'm making a backup managrer for my App (via iCloud). I did some tests and the basics worked. But few days later it stopped. I'm using NSMetadataQuery for searching if backup file exists. My backup files are named e.g. Backup29112011154133.xml where…
akashivskyy
  • 44,342
  • 16
  • 106
  • 116
5
votes
2 answers

List installed Applications on El Capitan using Spotlight in Swift 2.2

I am currently building a mac app which in the future should be able to kill and start apps on OS X. For that to be possible, I need to find a way to get a list of all the installed applications on the machine. I already did quite a bit of research…
bob_mosh
  • 267
  • 2
  • 17
5
votes
1 answer

Why is NSMetadataQueryDidUpdateNotification being called several times in quick succession?

In order to monitor file changes in my iCloud container, I've registered for [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(processiCloudUpdates:) …
n.evermind
  • 11,944
  • 19
  • 78
  • 122
4
votes
0 answers

iCloud Drive list directories and files through NSMetadataQuery

I have built an iCloud-enabled app named "rmc".My app now can upload files to iCloud Drive and get metadata by NSMetadataQuery.But NSMetadataQuery's results only include the files in my APP's Container.Please see this…
Tim
  • 51
  • 6
4
votes
1 answer

iCloud - NSMetadataQuery returning old results, showing deleted files

As the title says, my NSMetadataQueries to iCloud sometimes show files that I just deleted from iCloud. I can even download them after being deleted. Does anybody know what causes the queries to return wrong results / what can I do to prevent this?
Max
  • 2,699
  • 2
  • 27
  • 50
4
votes
0 answers

NSMetadataQuery sorting by update date is not working

I am trying to sort the results of a NSMetadataQuery by update date but it is not working. Here is my code: self.query = [[NSMetadataQuery new] autorelease]; [self.query setSearchScopes:@[NSMetadataQueryUbiquitousDataScope]]; NSSortDescriptor…
Thomas Castel
  • 553
  • 1
  • 6
  • 11
4
votes
1 answer

Block passed as a parameter to MDQuerySetSortComparatorBlock (Spotlight API) is not getting called

I tried to use MDQuerySetSortComparatorBlock method inside the MDQuery framework to sort the query result list. However, the block passed as a parameter to the method doesn't get called at all. Below is a piece of code that I'm using to make a query…
Shashank
  • 1,743
  • 1
  • 14
  • 20
4
votes
1 answer

How to limit NSMetadataQuery search results

I am performing spotlight like search using NSMetadataQuery, the problem i am facing is that i am not able to restrict NSMetadataQuery from searching the particular hidden folder like /Users/username/Library (as library is hidden folder). Any help…
Suhaiyl
  • 1,071
  • 9
  • 17
4
votes
1 answer

How do I make NSMetadataQuery see my saved documents' folders as packages?

I'm writing an app which saves and loads documents both locally and on iCloud. Locally is working fine, but I'm having a problem with iCloud. The documents are saved as a package - the UIDocument reads and writes an NSFileWrapper which contains an…
Simon
  • 25,468
  • 44
  • 152
  • 266
1
2 3 4 5