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]

InduSoft VBScript Webinar
 InduSoft VBScript Webinar InduSoft VBScript Webinar
InduSoft VBScript Webinar
AVEVA
 

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

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

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