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

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

What does this line of code mean?

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

The ? and :

相关标签:
13条回答
  • 2020-11-22 04:41
    int padding = ([[UIScreen mainScreen] bounds].size.height <= 480) ? 15 : 55;
    

    means

    int padding; 
    if ([[UIScreen mainScreen] bounds].size.height <= 480)
      padding = 15;
    else
      padding = 55; 
    
    0 讨论(0)
提交回复
热议问题