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

前端 未结 13 2424
南旧
南旧 2020-11-22 04:10

What does this line of code mean?

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

The ? and :

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 04:40

    This is part of C, so it's not Objective-C specific. Here's a translation into an if statement:

    if (inPseudoEditMode)
        label.frame = kLabelIndentedRec;
    else
        label.frame = kLabelRect;
    

提交回复
热议问题