The Binary Ternary Operator

TIL you could use the binary version of the ternary operator in XCode with clang. For instance:

NSString *possiblyNil;
label.text = possiblyNil ?: @"";

Very useful for safely coalescing nils before you output text, and at least a dozen other things.

Advertisements