Is this possible and how? I've only seen examples about using NSMetadataQuery
to search directories for files matching some predicate. I tried using this code
let query = NSMetadataQuery()
query.valueListAttributes = [NSMetadataUbiquitousItemPercentDownloadedKey]
query.predicate = NSPredicate(value: true)
let item = NSMetadataItem(url: url)!
query.searchItems = [item]
NotificationCenter.default.addObserver(forName: .NSMetadataQueryDidUpdate, object: query, queue: nil) { notification in
print(notification)
}
NotificationCenter.default.addObserver(forName: .NSMetadataQueryDidFinishGathering, object: query, queue: nil) { notification in
print(notification)
}
query.start()
but this gives the following exception
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unknown kind of NSPredicate given to NSMetadataQuery (TRUEPREDICATE)'
Without any predicate
the query doesn't seem to start at all, like mentioned in the official documentation.