Objective C Decision Making - Objective C

What is Objective C Decision Making?

  • Decision making structures specify the conditions to be evaluated or tested by the program. For this a programmer is required.
  • If conditions are tested to be true, the statements are executed. The other statements are executed if the condition is false.
  • The general form of a typical decision making structure:
  • Objective C assumes any non-zero and non-null values as true, and zero or null are assumed as false.

The following types of decision making statements in objective C are:

Objective C Decision Making

if statement
Anif statementconsists of a boolean expression followed by one or more statements.
if...else statement
Anif statementcan be followed by an optionalelse statement, which executes when the boolean expression is false.
nested if statements
You can use oneiforelse ifstatement inside anotheriforelse ifstatement(s).
switch statement
Aswitchstatement allows a variable to be tested for equality against a list of values.
nested switch statements
You can use oneswitchstatement inside anotherswitchstatement(s).

The ? : Operator

The general form of this operator is:

Here Exp1, Exp2 and Exp3 are expressions.
The value of a ? expression is determined as follows:

  • First Exp1 is evaluated. If it is true, Exp2 is evaluated and then the value of ? expression.
  • If Exp1 is false, then Exp3 is evaluated and this becomes the value of the expression.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Objective C Topics