In order to set up an asynchronous query looking for a specific application, I have a predicate of:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K LIKE[cd] %@ AND %K = %@",
@"kMDItemDisplayName", name,
@"kMDItemContentType", UTTypeApplicationBundle.identifier];
I tested it with standalone code, and this did what I wanted -- finding applications with the given name. But recently, it seems to have stopped working.
That query should be the equivalent of
mdfind 'kMDItemDisplayName LIKE[cd] "Safari" AND kMDItemContentType == "com.apple.application-bundle"'
but that gives me
Failed to create query for 'kMDItemDisplayName LIKE[cd] "Safari" AND kMDItemContentType == "com.apple.application-bundle"'.
If I drop the compound, and just do
% mdfind 'kMDItemDisplayName LIKE[cd] "Safari"'
then I get no output:
% mdfind 'kMDItemDisplayName LIKE[cd] "Safari"'
%
And yet clearly I do have Safari installed on my system.
What am I doing wrong, or missing? Anyone?