> On Feb 17, 2017, at 7:41 AM, sqwarqDev <sqwarq...@icloud.com> wrote: > > So eventually I discovered that this question has a history. Back in 2008 > Keary and Garriet discussed this: > > http://webcache.googleusercontent.com/search?q=cache:HXWdzJeGeDcJ:www.cocoabuilder.com/archive/cocoa/208612-nspredicate-containing-contains.html+&cd=4&hl=th&ct=clnk&gl=th&client=safari > > > Alas, none of that worked for me, but that’s exactly the same problem as > described. > > I also found some history of it on SO, but I don’t understand the “solution” > - which the asker confusingly says “I marking this as the solution even > though it doesn’t answer my question because my question was misleading”. > > http://stackoverflow.com/questions/11476466/use-an-nspredicate-to-detect-not-contains > > I’ve tried all the %K and so on options. I’ve actually even downloaded Xcode > 4 and built a test project in 10.7 Lion so I could debug it directly. Always > the same error: > > “Unknown type of NSComparisonPredicate given to NSMetadataQuery”. > > LIKE works, but as I said doesn’t give me the right results. MATCHES fails, > as does CONTAINS. I’m beginning to think this is a bug in NSMetadataQuery.
Have you read the File Metadata Search Programming Guide? You can find it here <https://developer.apple.com/library/content/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html#//apple_ref/doc/uid/TP40001849-CJBEJBHH> According to that document, only a very limited subset of predicate syntax is supported, and it uses special parsing rules. The correct syntax is probably: kMDItemFSName ==[c] *%@* As long as the parser is OK with the %@ placeholder, which the docs don’t state directly so an alternative would be to construct the string before passing to -predicateWithFormat: Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com