Learn Objective C Tutorial 1.11 Basics of If and Else

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
584 views
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Link to this comment:

Share to:

Uploader Comments (mybringback)

  • I am a beginner and I was wondering why do we need to put { } at the start and end of NSLog? it seems to run without it?

  • @brandongrenet good question. the { } are actually containers for the if/else functions. anything contained within the brackets will be executed for the if/else. the { } aren't directly related to NSLog. hopefully that helps!

see all

All Comments (6)

Sign In or Sign Up now to post a comment!
  • What if i want so make something that says if your an adult or a kid or a senior.

    I dont get how i use the comparison operators to say from 18-65 is adult. 18 or younger and 65 and older is easy. But how do you state from one age to another?

  • @brandongrenet If I am understanding you correctly you wrote your code without the { } characters in your if/else statements.

    Such as: if (age >= 18) NSLog(@"Eligible"); else NSLog(@"Not Eligible");

    The reason this works the same as if you had included { } characters around each NSLog statement is that your code only included a single statement in each if/else branch. If you wanted to do more in either if/else branch, you would need to surround the branch code with { } chars.

  • Nice video, any examples on how I could use that in a ipad/iphone app? (not age related though) like "if click here put them here, else leave them" or something

  • great videos

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more