• 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
Predicate syntax for a conditional expression?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Predicate syntax for a conditional expression?


  • Subject: Predicate syntax for a conditional expression?
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 06 Feb 2017 11:27:08 -0800

[Re-sending now that the lists are back up]

Conditional NSExpressions (NSConditionalExpressionType) were added in 2015, but Apple’s predicate format syntax document* hasn’t been updated, so I can’t find any description of what the syntax is for them in a predicate string.

By reverse-engineering (creating a conditional expression programmatically and then calling -description on it) I found that the syntax “TERNARY(test, iftrue, if false)” works. But this is pretty ugly**; I was hoping there was a cleaner syntax like “test ? iftrue : iffalse” or the more SQL-like “IF test THEN iftrue ELSE iffalse”. Would anyone happen to know if there’s an alternate non-functional syntax?

—Jens

* https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html <https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html>
** Unless you’re a LISP fan, I guess
_______________________________________________

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


  • Prev by Date: Change NSCursor globally
  • Next by Date: Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
  • Previous by thread: Re: Change NSCursor globally
  • Next by thread: Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
  • Index(es):
    • Date
    • Thread