iphone - What does the "?" mean in the following statement -


forgive "newbie" question, heck question mark, "?" mean in fololowing line of code?

self.navigationitem.leftbarbuttonitem.title = (editing) ?     nslocalizedstring(@"done", @"done") : nslocalizedstring(@"edit", @"edit"); 

this ternary statement, ? conditional operator. statement saying:

if (editing) {     self.navigationitem.leftbarbuttonitem.title = nslocalizedstring(@"done", @"done"); } else {     self.navigationitem.leftbarbuttonitem.title = nslocalizedstring(@"edit", @"edit"); } 

you think of like:

? - if previous statement true, code after.

: - else / otherwise, run code after this.

you can read more here http://en.wikipedia.org/wiki/ternary_operation. find construct available in many languages other c / objective-c.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -