What is the objective-c's ?, :?

Asked 2 years ago, Updated 2 years ago, 62 views

What does this code do? I don't know why I'm using ?and :p

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

objective-c c syntax conditional-operator operator

2022-09-21 21:08

1 Answers

?: is the same function as the trinomial operator in C. Expressing it in the form of an if statement

if(inPseudoEditMode) {
 label.frame = kLabelIndentedRect;
} } else {
 label.frame = kLabelRect;
}

It's like that.


2022-09-21 21:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.