Ternary Operator With Objective-C Objects

I previously wrote about C ternary operatar which provides an opportunity to write code that is “short-hand” if you will. A ternary operator is one that accepts three arguments, more on this below.

This is the traditional form of an if/else:

int x = 5;
 
...
 
if (x > 1)
  y = x;
else
  y = -1;

And here is a version using the ternary operators:

int y = x > 1 ? x : -1;

Continue reading