O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Functions in Objective-C and C Programming

667 visualizações

Publicada em

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

Learn about functions which allow you to organize your code into chunks. Functions allow you to delegate work between different blocks of code.

  • Login to see the comments

Functions in Objective-C and C Programming

  1. 1. Paul SoltiPhoneDev.tvFunctionsInstruction manuals for computers
  2. 2. Paul SoltiPhoneDev.tvOutline•Functions•Stack Frame•Recursion•Debugging•GlobalVariables
  3. 3. Paul SoltiPhoneDev.tv
  4. 4. Paul SoltiPhoneDev.tvDesk1. Build small drawer2. Build large drawer3. Build desk frame4. Insert small drawer5. Insert large drawer
  5. 5. Paul SoltiPhoneDev.tvArea = A x BAreaAB
  6. 6. Paul SoltiPhoneDev.tvint area(int sideA, int sideB)
  7. 7. Paul SoltiPhoneDev.tvint area(int sideA, int sideB)return type
  8. 8. Paul SoltiPhoneDev.tvint area(int sideA, int sideB)namereturn type
  9. 9. Paul SoltiPhoneDev.tvint area(int sideA, int sideB)name parameterreturn typeparameter
  10. 10. Paul SoltiPhoneDev.tvint area(int sideA, int sideB)
  11. 11. Paul SoltiPhoneDev.tvint area(int sideA, int sideB){int result = sideA * sideB;return result;}
  12. 12. Paul SoltiPhoneDev.tvint total = area(4, 2);
  13. 13. Paul SoltiPhoneDev.tvint total = area(4, 2);arguments
  14. 14. Paul SoltiPhoneDev.tvint total = area(4, 2);8arguments
  15. 15. Paul SoltiPhoneDev.tvint total = area(4, 2);
  16. 16. Paul SoltiPhoneDev.tvStack Frame•“Sandbox”•LocalVariables
  17. 17. Paul SoltiPhoneDev.tvStack Frame•“Sandbox”•LocalVariablesmain()total = area(4,2);
  18. 18. Paul SoltiPhoneDev.tvStack Frame•“Sandbox”•LocalVariablesmain()total = area(4,2);area(4,2)sideA = 4sideB = 2result = 8
  19. 19. Paul SoltiPhoneDev.tvStack Frame•“Sandbox”•LocalVariablesmain()total = area(4,2);
  20. 20. Paul SoltiPhoneDev.tvStack Frame•“Sandbox”•LocalVariablesmain()total = 8;
  21. 21. Paul SoltiPhoneDev.tvStack Frame•“Sandbox”•LocalVariables
  22. 22. Paul SoltiPhoneDev.tvArea
  23. 23. Paul SoltiPhoneDev.tvRecursionSpace Shuttle: CountdownTimer1. Display number2. Subtract one3. Repeat steps 1 and 2 (until 0) STS-110, NASA
  24. 24. Paul SoltiPhoneDev.tvRecursion
  25. 25. Paul SoltiPhoneDev.tvRecursionvoid countDown(int number) {if(number == 0) {printf("Take off!n");} else {printf("T-minus %d secondsn", number);int nextNumber = number - 1;countDown(nextNumber);}}
  26. 26. Paul SoltiPhoneDev.tvRecursionvoid countDown(int number) {if(number == 0) {printf("Take off!n");} else {printf("T-minus %d secondsn", number);int nextNumber = number - 1;countDown(nextNumber);}}
  27. 27. Paul SoltiPhoneDev.tvRecursionvoid countDown(int number) {if(number == 0) {printf("Take off!n");} else {printf("T-minus %d secondsn", number);int nextNumber = number - 1;countDown(nextNumber);}}
  28. 28. Paul SoltiPhoneDev.tvStack Frame
  29. 29. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)
  30. 30. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)
  31. 31. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)
  32. 32. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)
  33. 33. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)countDown(2)nextNumber = 1countDown(1)
  34. 34. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)countDown(2)nextNumber = 1countDown(1)countDown(1)nextNumber = 0countDown(0)
  35. 35. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)countDown(2)nextNumber = 1countDown(1)countDown(1)nextNumber = 0countDown(0)countDown(0)take off!
  36. 36. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)countDown(2)nextNumber = 1countDown(1)countDown(1)nextNumber = 0countDown(0)
  37. 37. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)countDown(2)nextNumber = 1countDown(1)
  38. 38. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)countDown(3)nextNumber = 2countDown(2)
  39. 39. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)countDown(4)nextNumber = 3countDown(3)
  40. 40. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)countDown(5)nextNumber = 4countDown(4)
  41. 41. Paul SoltiPhoneDev.tvStack Framemain()startNumber = 5countDown(5)
  42. 42. Paul SoltiPhoneDev.tvStack Frame
  43. 43. Paul SoltiPhoneDev.tvCountDown!
  44. 44. Paul SoltiPhoneDev.tvGlobalVariablesint total = 10resetTotal()total = 0;updateTotal()total = total + 1;
  45. 45. Paul SoltiPhoneDev.tvGlobalVariables
  46. 46. Paul SoltiPhoneDev.tvReview•Functions•Stack Frame•Recursion•Debugging•GlobalVariables
  47. 47. Paul SoltiPhoneDev.tv

×