iOS Development

Course No. 10-152-139

Chapter 4 — if/else

You’ve seen something just about the same as this before

  • Could you be sure what language the above code is from?

How about this?

Comparison operators

< Is the number on the left less than the number on the right?
> Is the number on the left greater than the number on the right?
<= Is the number on the left less than or equal to the number on the right?
>= Is the number on the left greater than or equal to the number on the right?
== Are they equal?
!= Are they not equal?
  • What’s the same as other languages you’ve learned?
  • What’s different from other languages you’ve learned?

Logical operators

&& Logical AND — true if and only if both are true
|| Logical OR — false if and only if both are false
! Logical NOT — true becomes false, false becomes true

Boolean variables

  • Add this to code that uses BOOL
  • Use of BOOL

else if

  • This should look familar

For the More Curious: Conditional (ternary) operator

  • What does this do?