NSPredicate format strings: How to quote a space in a key path?
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