• 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
NSPredicate format strings: How to quote a space in a key path?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPredicate format strings: How to quote a space in a key path?


  • Subject: NSPredicate format strings: How to quote a space in a key path?
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 05 Aug 2014 10:31:03 -0700

I can't figure out how to handle key-paths that contain spaces, in NSPredicate format strings. There doesn't seem to be any way to escape the space character.

For example, I've got a data set parsed from my iTunes library, so every item has a "Total Time" key. How do I write a format string involving this key? I've tried:
	'Total Time' < 60000
	Total\ Time < 60000
	Total\x20Time < 60000
None of these work. The first treats 'Total Time' as a string literal not a key-path, and the others don't parse at all (even though the Predicate Format String Syntax reference says \x is supported.)

I know I can use %K and then plug @"Total Time" in as a parameter, but in this case I want the user to be able to type in these format strings, so that's not going to work.

—Jens
_______________________________________________

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: NSPredicate format strings: How to quote a space in a key path?
      • From: Sean McBride <email@hidden>
  • Prev by Date: Is substitution of block-function parameters OK when it's an object type?
  • Next by Date: Re: NSPredicate format strings: How to quote a space in a key path?
  • Previous by thread: Re: Is substitution of block-function parameters OK when it's an object type?
  • Next by thread: Re: NSPredicate format strings: How to quote a space in a key path?
  • Index(es):
    • Date
    • Thread