• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Some help with NSComparisonPredicate please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Some help with NSComparisonPredicate please


  • Subject: Some help with NSComparisonPredicate please
  • From: sqwarqDev <email@hidden>
  • Date: Wed, 15 Feb 2017 22:50:38 +0700

Building with Xcode 7.3.1, macOS 10.11.6

I’m using an NSPredicate with the form:

NSString *targetString = @“some string or other”;
NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"kMDItemFSName contains[cd] %@“, targetString]];


When I build and run my app, this runs fine on 10.9 and 10.11. However, when I build and run my app on 10.7, exercising the search function that calls the above code causes a crash and the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unknown type of NSComparisonPredicate given to NSMetadataQuery (kMDItemFSName CONTAINS[cd] “target filename”)’

The docs tell me that:

kMDItemFSName has been around since 10.4
NSContainsPredicateOperatorType has been around since 10.5

However, the docs also say that NSContainsPredicateOperatorType requires the left hand side to be a collection (array, set, dictionary), whereas I have a string. And yet, it works on 10.9 and later. My attempts at trying to put kMDItemFSName into an array on the left hand side have ended in build-time or run-time failures.

Any thoughts on how I can get a ‘contains' query to run on 10.7?


TIA


Phil




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Some help with NSComparisonPredicate please
      • From: sqwarqDev <email@hidden>
  • Prev by Date: Re: Problem with NSWindowCollectionBehaviorCanJoinAllSpaces
  • Next by Date: Re: Sometimes all my menus are disabled
  • Previous by thread: Watch extension running old version
  • Next by thread: Re: Some help with NSComparisonPredicate please
  • Index(es):
    • Date
    • Thread