
- Basic Objective-C
- Objective-C - Home
- Objective-C - Overview
- Objective-C - Environment Setup
- Objective-C - Program Structure
- Objective-C - Basic Syntax
- Objective-C - Data Types
- Objective-C - Variables
- Objective-C - Constants
- Objective-C - Operators
- Objective-C - Loops
- Objective-C - Decision Making
- Objective-C - Functions
- Objective-C - Blocks
- Objective-C - Numbers
- Objective-C - Arrays
- Objective-C - Pointers
- Objective-C - Strings
- Objective-C - Structures
- Objective-C - Preprocessors
- Objective-C - Typedef
- Objective-C - Type Casting
- Objective-C - Log Handling
- Objective-C - Error Handling
- Command-Line Arguments
- Advanced Objective-C
- Objective-C - Classes & Objects
- Objective-C - Inheritance
- Objective-C - Polymorphism
- Objective-C - Data Encapsulation
- Objective-C - Categories
- Objective-C - Posing
- Objective-C - Extensions
- Objective-C - Protocols
- Objective-C - Dynamic Binding
- Objective-C - Composite Objects
- Obj-C - Foundation Framework
- Objective-C - Fast Enumeration
- Obj-C - Memory Management
- Objective-C Useful Resources
- Objective-C - Quick Guide
- Objective-C - Useful Resources
- Objective-C - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
break statement in Objective-C
The break statement in Objective-C programming language has the following two usages −
When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop.
It can be used to terminate a case in the switch statement (covered in the next chapter).
If you are using nested loops (i.e., one loop inside another loop), the break statement will stop the execution of the innermost loop and start executing the next line of code after the block.
Syntax
The syntax for a break statement in Objective-C is as follows −
break;
Flow Diagram

Example
#import <Foundation/Foundation.h> int main () { /* local variable definition */ int a = 10; /* while loop execution */ while( a < 20 ) { NSLog(@"value of a: %d\n", a); a++; if( a > 15) { /* terminate the loop using break statement */ break; } } return 0; }
When the above code is compiled and executed, it produces the following result −
2013-09-07 22:15:46.905 demo[12282] value of a: 10 2013-09-07 22:15:46.906 demo[12282] value of a: 11 2013-09-07 22:15:46.906 demo[12282] value of a: 12 2013-09-07 22:15:46.906 demo[12282] value of a: 13 2013-09-07 22:15:46.906 demo[12282] value of a: 14 2013-09-07 22:15:46.906 demo[12282] value of a: 15
objective_c_loops.htm
Advertisements