diff options
| author | Yannick Loriot <yannick.loriot@gmail.com> | 2013-08-13 16:22:40 +0200 | 
|---|---|---|
| committer | Yannick Loriot <yannick.loriot@gmail.com> | 2013-08-13 16:22:40 +0200 | 
| commit | 24d9cde4883202d4b7c5db7dad8981b4a4000125 (patch) | |
| tree | efbb31810d1c10c0d6cb955fdf106e752399a16e | |
| parent | 0970cb8010e590332b86de26a4746c7202c22363 (diff) | |
[NEW] Statements
| -rw-r--r-- | objective-c.html.markdown | 72 | 
1 files changed, 72 insertions, 0 deletions
| diff --git a/objective-c.html.markdown b/objective-c.html.markdown index 7f87da6f..ebae2fc7 100644 --- a/objective-c.html.markdown +++ b/objective-c.html.markdown @@ -99,6 +99,78 @@ int main (int argc, const char * argv[])      ///////////////////////////////////////      // Operators      /////////////////////////////////////// +     +    // The operators works like in the C language +    // For example: +    3 == 2; // => 0 (NO) +    3 != 2; // => 1 (YES) +    1 && 1; // => 1 (Logical and) +    0 || 1; // => 1 (Logical or) +    ~0x0F; // => 0xF0 (bitwise negation) +    0x0F & 0xF0; // => 0x00 (bitwise AND) +    0x01 << 1; // => 0x02 (bitwise left shift (by 1)) + +    /////////////////////////////////////// +    // Control Structures +    /////////////////////////////////////// + +    // If-Else statement +    if (NO) +    { +        NSLog(@"I am never run"); +    } else if (0) +    { +        NSLog(@"I am also never run"); +    } else +    { +        NSLog(@"I print"); +    } + +    // Switch statement +    switch (2) { +        case 0: +        { +            NSLog(@"I am never run"); +        } break; +        case 1: +        { +            NSLog(@"I am also never run"); +        } break; +        default: +        { +            NSLog(@"I print"); +        } break; +    } +     +    // While loops exist +    int ii = 0; +    while (ii < 4) +    { +        NSLog(@"%d,", ii++); // ii++ increments ii in-place, after using its value. +    } // => prints "0,  +                    1, +                    2, +                    3," + +    // For loops too +    int jj; +    for (jj=0; jj < 4; jj++) +    { +        NSLog(@"%d,", ii++); +    } // => prints "0,  +                    1, +                    2, +                    3," +      +    // Foreach                +    NSArray *values = @[@0, @1, @2, @3]; +    for (NSNumber *value in values) +    { +        NSLog(@"%@,", value); +    } // => prints "0,  +                    1, +                    2, +                    3,"      // Clean up the memory you used into your program      [pool drain]; | 
