User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







objective-c:control_structures:if

if

    if ( condition == true ){
    command;    
    }

if example 1 objective c

    NSString *string = @"i wouldn't want to go anywhere without my wonderful towel";
 
    if ([string isEqualToString:@"i wouldn't want to go anywhere without my wonderful towel"]) {
        NSInteger a=42;
        NSLog(@"correct %i", a);
    }
 
    else if ([string isEqualToString:@"42"]) {
        NSLog(@"Sorry but the answer is not correct");
    }

output

  2012-10-12 00:35:34.234 cppApp[39677:c07] 42

if example 2 objective c

        NSInteger a;
        for (a=0;a<=99;a++) {
            if (a < 42 || a > 42) {
                NSLog(@"what ? %i", a);
            } else {
                NSLog(@"correct ;)");
            }
        }

output

  ....
  2012-10-12 00:45:34.813 cppApp[39677:c07] what ? 41
  2012-10-12 00:45:34.814 cppApp[39677:c07] correct ;)
  2012-10-12 00:45:34.815 cppApp[39677:c07] what ? 43
advertising
objective-c/control_structures/if.txt · Last modified: 2012/12/20 12:24 (external edit)

Impressum Datenschutz