Re: Weird NSPredicate structure when using "first" in keypath
Re: Weird NSPredicate structure when using "first" in keypath
- Subject: Re: Weird NSPredicate structure when using "first" in keypath
- From: Chris Hanson <email@hidden>
- Date: Tue, 17 Jan 2017 19:18:39 -0800
On Jan 9, 2017, at 8:29 PM, Jens Alfke <email@hidden> wrote:
> On Jan 9, 2017, at 6:38 PM, Aaron Tuller <email@hidden> wrote:
>> Try doing
>> name.#first
>> as FIRST and LAST are reserved words and need escaping:
>
> Thanks for the answer. Unfortunately this is a library that will allow developers to provide their own predicate strings, and I can imagine this causing confusion (and therefore support requests for us.)
>
> I added a workaround to my code that will recognize the weird predicates formed by using unescaped ‘first’ and ‘last’, and handle them appropriately. I hope that’ll be robust enough!
If that's the case, why not just provide your library's API in terms of NSPredicate objects?
Then if your users want to use a predicate string (rather than an NSPredicateEditor or other form of direct instantiation) they still trivially can, but it's on them to get the syntax correct rather than on you to try to figure out their intent.
-- Chris
_______________________________________________
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