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

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

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