SlideShare a Scribd company logo
1 of 24
Download to read offline
FTS seminar
 27.01.2010




          iPhone Programming
             in ~30 mins (?)
               Diego Pizzocaro
Disclaimer

These slides are heavily based on Evan Doll and Alan Cannistraro’s
    slides prepared for iPhone App Programming course @ Stanford



              http://www.stanford.edu/class/cs193p



              Look for iPhone Application Programming
                       in iTunes U for videopodcasts.
Crash course

• iPhone OS overview
• Objective-C
• Model-View-Controller (MVC)
iPhone OS overview
iPhone
Mac OS X


    Cocoa

    Media

 Core Services

   Core OS
iPhone


Cocoa Touch     UI application framework
                which as a developer you
   Media        are using the most

Core Services

  Core OS
Developing on iPhone

     Tools
 Tools
Tools
                           Xcode                     Interface Builder
                          Xcode
                         Xcode                Interface Builder
                                             Interface Builder
      Tools
                           Xcode            Interface Builder
                                       Cocoa Touch
 Frameworks
Frameworks
     Frameworks
     Frameworks
                        Foundation
                       Foundation                      UIKit
                                                       UIKit
                          Foundation
                         Foundation               UIKit   UIKit



 Language
Language
      Language        [textView setStringValue: @“Hello”];
                       [textView setStringValue: @“Hello”];
                     [textView setStringValue: @“Hello”];
  (& Runtime)
(& Runtime)
       (& Runtime)
      Language         [textView setStringValue: @“Hello”];
                                    Objective-C
                                   Objective-C
                                   Objective-C
     (& Runtime)                       Objective-C
Objective-C
Objective-C
•   Strict superset of C

    ‣   Mix C with Obj-C



•   Object oriented language

•   Based on message passing (similar to Smalltalk)




•   No garbage collector need to manually manage memory
    (not covered in this presentation)
Message Syntax

[receiver message];



[receiver message:argument];



[receiver message:arg1 andArg:arg2];
Message Examples

BankAccount *myAccount; //assume this exists

int n = [myAccount accountNumber];


[myAccount deposit:100];



if([myAccount isNotEmpty]) {
    [myAccount withdraw:50 printReceipt:YES];

}
Some new types
•   Anonymous Objects

•   Class

•   ...others but no time!
    (Selectors “SEL”, Boolean “BOOL”, etc.)
Anonymous Objects

•   Normal (or Statically-typed) object
    BankAccount *anAccount




•   Anonymous (or Dynamically-typed) object
    id anAccount

    - Just id (Not id*)
    - id is the data type that indicates that we are talking about an object
Class
•   class instances responds to instance methods “-”
    - (id)init;
    - (double)accountNumber;


                   int n = [myAccount accountNumber];




•   classes responds to class methods “+” (like Java “static” methods)
    + (id)alloc;
    + (float)stdInterestRate;


                   float rate = [BankAccount stdInterestRate];
Defining aaclass
             Defining a class
              Defining class
A public header and a private implementation
   A public header and a private implementation
      A public header and a private implementation




         Header File File
             Header
            Header File        Implementation File
                             Implementation File File
                                 Implementation
Defining a class
             Defining a class
                  Demo
A public header and a private implementation
   A public header and a private implementation
                    BankAccount class




            BankAccount.h
         Header File File
             Header             BankAccount.m
                             Implementation File File
                                 Implementation
Model - View - Controller (MVC)
Address Book
App Architecture




Model                      View




             Controller
MVC
•   Only the Controller knows both Model and View

•   Makes code more reusable (especially the Model part)




                                                                  Interface Builder




                  Model                                    View




                                       Controller
       Xcode
Demo
                               BankAccount app
                                                       View
    Model        ✓                                   MainWindow.xib


    BankAccount
   BankAccount
  BankAccount
  balance
 balance
balance                                              Value Changed
  - initWithBalance                                     EVENT
- -initWithBalance
 -initWithBalance
    setBalance
 -setBalance
   setBalance
- - balance
--balance
   balance


                                Controller
                                 AccountController

                                slider
                  Outlets
                                label
                                myBankAccount

                      Action    - updateAccount
Demo
                      BankAccount app
                                              View
    Model        ✓                          MainWindow.xib


    BankAccount
   BankAccount
  BankAccount
  balance
 balance
balance                                     Value Changed
  - initWithBalance                            EVENT
- -initWithBalance
 -initWithBalance
    setBalance
 -setBalance
   setBalance
- - balance
--balance
   balance


                       Controller
                        AccountController

                       slider
                       label
                       myBankAccount

                       - updateAccount
Your turn! ;)
                       •      http://www.stanford.edu/class/cs193p

                       •      http://cs193p.com/

                       •      iTunes U - “iPhone Application Programming”

                       •      iPhone Developer Program
                              (FREE, but cannot deploy on real iPhone)




                       •      users.cs.cf.ac.uk/D.Pizzocaro




Image from: http://www.trumpetvine.com/sketchblog/wp-content/images/2007.07/iphone_lg.jpg

More Related Content

Similar to iPhone Programming in 30 minutes (?) [FTS]

Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyUna Daly
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1willmation
 
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...Chris Richardson
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titaniumNaga Harish M
 
Best Apple IOS Training in Chennai | Best Iphone Training in Chennai
Best Apple IOS Training in Chennai | Best Iphone Training in ChennaiBest Apple IOS Training in Chennai | Best Iphone Training in Chennai
Best Apple IOS Training in Chennai | Best Iphone Training in ChennaiCore Mind
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application developmentZoltán Váradi
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1Rich Helton
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumTechday7
 
I pad uicatalog_lesson02
I pad uicatalog_lesson02I pad uicatalog_lesson02
I pad uicatalog_lesson02Rich Helton
 
NDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDDNDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDDjbandi
 
InduSoft VBScript Webinar
 InduSoft VBScript Webinar InduSoft VBScript Webinar
InduSoft VBScript WebinarAVEVA
 
iOS overview
iOS overviewiOS overview
iOS overviewgupta25
 
Cappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkCappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkAndreas Korth
 
iOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomeriOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomerAndri Yadi
 

Similar to iPhone Programming in 30 minutes (?) [FTS] (20)

Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1
 
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
 
Best Apple IOS Training in Chennai | Best Iphone Training in Chennai
Best Apple IOS Training in Chennai | Best Iphone Training in ChennaiBest Apple IOS Training in Chennai | Best Iphone Training in Chennai
Best Apple IOS Training in Chennai | Best Iphone Training in Chennai
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application development
 
From mvc to viper
From mvc to viperFrom mvc to viper
From mvc to viper
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1LEARNING	 iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
LEARNING  iPAD STORYBOARDS IN OBJ-­‐C LESSON 1
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
 
I pad uicatalog_lesson02
I pad uicatalog_lesson02I pad uicatalog_lesson02
I pad uicatalog_lesson02
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
NDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDDNDC 2011 - Building .NET Applications with BDD
NDC 2011 - Building .NET Applications with BDD
 
Eclipse e4
Eclipse e4Eclipse e4
Eclipse e4
 
InduSoft VBScript Webinar
 InduSoft VBScript Webinar InduSoft VBScript Webinar
InduSoft VBScript Webinar
 
iOS overview
iOS overviewiOS overview
iOS overview
 
Cappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkCappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application Framework
 
iOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomeriOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for Jasakomer
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

iPhone Programming in 30 minutes (?) [FTS]

  • 1. FTS seminar 27.01.2010 iPhone Programming in ~30 mins (?) Diego Pizzocaro
  • 2. Disclaimer These slides are heavily based on Evan Doll and Alan Cannistraro’s slides prepared for iPhone App Programming course @ Stanford http://www.stanford.edu/class/cs193p Look for iPhone Application Programming in iTunes U for videopodcasts.
  • 3. Crash course • iPhone OS overview • Objective-C • Model-View-Controller (MVC)
  • 6. Mac OS X Cocoa Media Core Services Core OS
  • 7. iPhone Cocoa Touch UI application framework which as a developer you Media are using the most Core Services Core OS
  • 8. Developing on iPhone Tools Tools Tools Xcode Interface Builder Xcode Xcode Interface Builder Interface Builder Tools Xcode Interface Builder Cocoa Touch Frameworks Frameworks Frameworks Frameworks Foundation Foundation UIKit UIKit Foundation Foundation UIKit UIKit Language Language Language [textView setStringValue: @“Hello”]; [textView setStringValue: @“Hello”]; [textView setStringValue: @“Hello”]; (& Runtime) (& Runtime) (& Runtime) Language [textView setStringValue: @“Hello”]; Objective-C Objective-C Objective-C (& Runtime) Objective-C
  • 10. Objective-C • Strict superset of C ‣ Mix C with Obj-C • Object oriented language • Based on message passing (similar to Smalltalk) • No garbage collector need to manually manage memory (not covered in this presentation)
  • 11. Message Syntax [receiver message]; [receiver message:argument]; [receiver message:arg1 andArg:arg2];
  • 12. Message Examples BankAccount *myAccount; //assume this exists int n = [myAccount accountNumber]; [myAccount deposit:100]; if([myAccount isNotEmpty]) { [myAccount withdraw:50 printReceipt:YES]; }
  • 13. Some new types • Anonymous Objects • Class • ...others but no time! (Selectors “SEL”, Boolean “BOOL”, etc.)
  • 14. Anonymous Objects • Normal (or Statically-typed) object BankAccount *anAccount • Anonymous (or Dynamically-typed) object id anAccount - Just id (Not id*) - id is the data type that indicates that we are talking about an object
  • 15. Class • class instances responds to instance methods “-” - (id)init; - (double)accountNumber; int n = [myAccount accountNumber]; • classes responds to class methods “+” (like Java “static” methods) + (id)alloc; + (float)stdInterestRate; float rate = [BankAccount stdInterestRate];
  • 16. Defining aaclass Defining a class Defining class A public header and a private implementation A public header and a private implementation A public header and a private implementation Header File File Header Header File Implementation File Implementation File File Implementation
  • 17. Defining a class Defining a class Demo A public header and a private implementation A public header and a private implementation BankAccount class BankAccount.h Header File File Header BankAccount.m Implementation File File Implementation
  • 18. Model - View - Controller (MVC)
  • 20. App Architecture Model View Controller
  • 21. MVC • Only the Controller knows both Model and View • Makes code more reusable (especially the Model part) Interface Builder Model View Controller Xcode
  • 22. Demo BankAccount app View Model ✓ MainWindow.xib BankAccount BankAccount BankAccount balance balance balance Value Changed - initWithBalance EVENT - -initWithBalance -initWithBalance setBalance -setBalance setBalance - - balance --balance balance Controller AccountController slider Outlets label myBankAccount Action - updateAccount
  • 23. Demo BankAccount app View Model ✓ MainWindow.xib BankAccount BankAccount BankAccount balance balance balance Value Changed - initWithBalance EVENT - -initWithBalance -initWithBalance setBalance -setBalance setBalance - - balance --balance balance Controller AccountController slider label myBankAccount - updateAccount
  • 24. Your turn! ;) • http://www.stanford.edu/class/cs193p • http://cs193p.com/ • iTunes U - “iPhone Application Programming” • iPhone Developer Program (FREE, but cannot deploy on real iPhone) • users.cs.cf.ac.uk/D.Pizzocaro Image from: http://www.trumpetvine.com/sketchblog/wp-content/images/2007.07/iphone_lg.jpg