'How to update query string in MDQuery?
I'm trying to perform a Spotlight search using MDQuery on macOS. I'm able to create an initial query using MDQueryCreate, but I'm not sure how to update its query string to update the search results.
In NSMetadataQuery, I could simply update the predicate property of my query instance and run the query again. Is there something similar for MDQuery? Or should I be simply creating new query instances using MDQueryCreate for every new query string? I would be showing search results as the user types into a search box, so I'm not sure if creating a new instance of MDQuery for each new query string is a good idea.
let mdQuery = MDQueryCreate(kCFAllocatorDefault, "kMDItemDisplayName == \"*cert*\"c" as CFString, nil, nil)
MDQuerySetMaxCount(mdQuery, 50)
MDQueryExecute(mdQuery, CFOptionFlags(kMDQueryWantsUpdates.rawValue))
// later...
// how do I update the query string for mdQuery?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
