objective-c operator ?:

Discussion in 'Mac Programming' started by medasmx, May 12, 2009.

  1. medasmx macrumors member

    Nov 9, 2008
    In an apple developer example(DragNDropOutlineView), the following line of code is present --

    I haven't been able to find documentation regarding this online. However, in the Kochan book, a?b:c is called a conditional(if...then, I suppose). It would read if a is true then b otherwise c. From the above statement to me that means, if item==nil then treeData otherwise item. The full block of code is ...

    - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
        SimpleTreeNode *node = (item == nil) ? treeData : item;
        return [node numberOfChildren];
    Thanks for any explanation. Adam
  2. SilentPanda Moderator emeritus


    Oct 8, 2002
    The Bamboo Forest
  3. medasmx thread starter macrumors member

    Nov 9, 2008

Share This Page