loops and objective-c and c programming

12
Paul Solt iPhoneDev.tv Loops Can you repeat what you said again?

Upload: paul-solt

Post on 28-Nov-2014

710 views

Category:

Technology


1 download

DESCRIPTION

Course Link: http://skl.sh/11kA0im Website: http://iPhoneDev.tv

TRANSCRIPT

Page 1: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

LoopsCan you repeat what you said again?

Page 2: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

Overview•Loops

•while loop

•for loop

•break

•continue

Page 3: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

Loops•Why?

•Data processing

• Image processing

•Gameplay

Page 4: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

Count DownT-minus 5 secondsT-minus 4 secondsT-minus 3 secondsT-minus 2 secondsT-minus 1 seconds

Take off!

Page 5: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

while loop

// 1. Setupwhile( /* 2. Condition */ ) { // 3. Do work // 4. Condition step}

Page 6: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

while loopint seconds = 5; while(seconds > 0) { printf("T-minus %d seconds\n", seconds); seconds--;}printf("Take off!");

Page 7: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

for loop

for( /* 1. Setup */ ; /* 2. Condition */ ; /* 3. Condition step */) { // 4. Do Work}

Page 8: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

for loop

int seconds; for(seconds = 5; seconds > 0; seconds--) { printf("T-minus %d seconds\n", seconds);}printf("Take off!");

Page 9: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

breakfor(seconds = 5; seconds > 0; seconds--) { if(engineFailure) { break; } printf("T-minus %d seconds\n", seconds);}

Page 10: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

continuewhile(!gameOver) { if(skipCardPlayed) { nextPerson(); continue; } playCard(); nextPerson();}

Page 11: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv

Review•while loop

•for loop

•break

•continue

Page 12: Loops and Objective-C and C Programming

Paul Solt iPhoneDev.tv