Alex Rivera | Logout

What does the question mark and the colon (?: ternary operator) mean in objective-c?

Asked 2010-04-07T19:44:04.417
293

What does this line of code mean?

label.frame = (inPseudoEditMode) ? kLabelIndentedRect : kLabelRect;

The ? and : confuse me.

Edit
Report

1 Answer

4

It's just a short form of writing an if-then-else statement. It means the same as the following code:

if(inPseudoEditMode)
  label.frame = kLabelIndentedRect;
else
  label.frame = kLabelRect;
answered 2010-04-07T19:46:58.317

Your Answer