I was reading over the Dropbox API and I found this line:
NSString* title = [[DBSession sharedSession] isLinked] ? @"Unlink Dropbox" : @"Link Dropbox";
I’ve never seen that syntax before? What is it called and what does it mean? I can tell what it does just from looking at it but could someone tell me about it?
That is a so-called ternary operator
Ternary operators in C have the following pattern
condition ? true-expression : false-expression.If
conditionevaluates toYES, thentrue-expressiongets evaluated, otherwisefalse-expression.In your particular case
titlewould get assigned to@"Unlink Dropbox"if[[DBSession sharedSession] isLinked]returnsYES, otherwise@"Link Dropbox".