What does this line of code mean?
label.frame = (inPseudoEditMode) ? kLabelIndentedRect : kLabelRect;
The ?
and :
As everyone referred that, It is a way of representing conditional operator
if (condition){
true
}
else {
false
}
using ternary operator (condition)? true:false
To add additional information, In swift we have new way of representing it using ??
.
let imageObject: UIImage = (UIImage(named: "ImageName")) ?? (initialOfUsername.capitalizedString).imageFromString
Which is similar to
int a = 6, c= 5;
if (a > c)
{
a is greater
} else {
c is greater
}
is equivalent to
if (a>c)?a:c
==> Is equal to if (a>c)?:c
instead of ?:
we can use ??
is swift.