Forgive my “newbie” question, but what the heck does the question mark, “?” mean in the fololowing line of code?
self.navigationItem.leftBarButtonItem.title = (editing) ?
NSLocalizedString(@"Done", @"Done") : NSLocalizedString(@"Edit", @"Edit");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a ternary statement, the
?is the conditional operator. The statement is basically saying:You could think of it like:
?– If previous statement is true, do code immediately after.:– Else / Otherwise, run the code immediately after this.You can read more here http://en.wikipedia.org/wiki/Ternary_operation. You will find that this construct is available in many languages other than C / Objective-C.