SlideShare a Scribd company logo
1 of 23
Download to read offline
Bootstrapping iPhone Development


Munjal Budhabhatti
Senior Consultant
Sep/24/2009
San Antonio
Agenda

!!Current state of iPhone Development
!!Fast track to Objective – C
!!Fast track to XCode and Interface Builder
!!Getting productive using OR-Framework, Testing,
  Serialization
Current state of iPhone Development
•!   Requirements
      –! Intel based Mac with OSX 10.5
      –! iPhone SDK (Sign-up for iPhone Developer Program $99 for a year)
      –! Do NOT need iPhone or iPod Touch (Work on iPhone Simulator)

•!   Developer Resources
      http://developer.apple.com/iphone
      http://devforums.apple.com
      http://cs193p.stanford.edu
Fast track to Objective – C


•!   Object oriented programming language to write Applications for
     iPhone and Mac OS

•!   Powerful set of extensions to the standard ANSI C language
      –! Object oriented
      –! Dynamic (Adds Smalltalk-style or Ruby-style messaging)

•!   You manage your memory – Probably a good thing in mobile devices
Objective – C Syntax

•!   Objective – C is a strict superset thin layer on top of ANSI C

•!   Compile any ANSI C program with Objective – C compiler

•!   Object syntax derived from Smalltalk

•!   Non object oriented syntax identical to C

•!   A bit clumsy syntax. Can get lost in the woods. Do NOT let the syntax
     defeat you.
Coding in Objective – C

•!   Classes are developed using a header and an implementation.

•!   Names and types of instance variables and method signature in
     header file. Implement methods in implementation file
                 Interface                                Implementation
      @interface classname : superclassname {   @implementation classname
           //instance variables                   + classMethod1 {
      }                                         }
           +classMethod1;                         + (returnType) classMethod2 {
           +(returnType) classMethod2;          }
           -instanceMethod1;                      - instanceMethod1 {
           -(returnType) instanceMethod2;       }
      @end                                        - (returnType) instanceMethod2 {
                                                }
Messages (Methods) in Objective – C

•!   Java and C# implements Simula-style programming model: a method
     is bound to section of code in a compiler

•!   Objective – C is based on sending messages to object instances.
     Message is simply a name, resolved at runtime by the receiving object.

•!   fullName = [firstName stringByAppendingString: lastName]

•!   No type-checking. If the object cannot respond to a message it simply
     ignores it. No NULL checking!! Yay!!
Static and Dynamic Typing Objective – C


•!   Static typing using NSObject – the mother of almost all objects. You
     can have objects that don’t derive from NSObject.

•!   Dynamic typing using id

      –! Sending messages to Nil is OK

      –! Dynamic objection creation: objc_getClass, class_createInstance,
        class_getInstanceMethod, class_getInstanceVariable

      –! TypeIntrospection : isMemberOfClass & isKindOfClass
Invocation and Memory Management in Objective – C




•!   Memory management possible using Garbage collector for Mac OS

•!   You manage your memory for iPhone OS

•!   LeanManager *ronCampbell = [[LeanManager alloc] init];
Protocols in Objective – C

•!   Supports multiple-inheritance of specification

•!   Similar to Interface in C# and Java. However, the methods could be
     optional.

•!   Used to declare methods that could be implemented by any class

•!   Used to declare interface to an object while concealing its class

•!   Used to capture similarities among classes that are not in hierarchy
Protocol Example in Objective – C


   @protocol Serialization   @interface AccountImage : Image <Serialization>
    - (void) serialize;       - (void) serialize;
    - (void) deserialize;     - (void) deserialize;
   @end                      @end
Forwarding in Objective – C


•!   Dynamic nature of Objective C allows forwarding of messages

•!   If an object doesn’t respond to a message, it can forward to one that
     probably could.

•!   Similar to method_missing in Ruby

•!   ages = [persons age]
Category in Objective – C

•!   A category allows you to add methods to an existing class – even for
     ones that you don’t own or have the source code

•!   Allows to extend the functionality without subclassing

•!   Split the implementation of your class between several files

•!   Caveat: Cannot create new instance variable in a class
Fast track to Interface Builder


•!   App for iPhone devs to create GUI

•!   Typical MVC pattern. Write models and controllers in Xcode. Build
     interface in Interface Builder

•!   One could build interface using code. However, I would advise to bear
     the pain once and learn using Interface Builder with Xcode.

•!   Nib file and the magic
Fast Track to OR-framework such as Active Record




•!   Beautify your models

      –! Will you make raw SQL calls ?

•!   Start using ObjectPersistentFramework
Fast track to Testing




•!   Test using GoogleToolbox

•!   Mock using OCMock

•!   Serialization using JSON framework for iPhone
iPhone development fundamentals


•!   Cocoa Touch – Framework to develop touchscreen applications: UI
     elements, event dispatching, application lifecycle

•!   Media – Graphics, animations, sound, video

•!   Core Services – Collections, Strings, Location, SQLLite, Networking

•!   Core OS Layer – Standard IO/, Power Management
main() method

•!   Java/C# developers look for “main()” method

•!   NSApplication provides the central framwork for app execution

•!   Every app creates one instance of NSApplication in main()

•!   After NSApplication creation, load the Nib file and start event loop

•!   Nib file loads the UI

•!   applicationDidFinishLauching() method called when app is launched
View Controllers
•!   Model View Controller Pattern

•!   Each view in an iPhone app is managed by UIViewController

•!   Mother of all view classes

•!   Importance of IBAction and IBOutlet

•!   IBAction: editButtonClicked()
•!   IBOutlet: UILabel
Table View Controller


•!   Define and populate NSMutableArray in initWithCoder

•!   Implement numberOfRowsInSection protocol for tabelView

•!   Implement cellForRowAtIndexPath

•!   Improve performance by reusing cells
Navigation Controller

•!   Mail app is the best way to understand navigation controller

•!   Navigation controller maintains stack of view controllers

•!   Each controller represents one node in hierarchy

•!   Typical push and pop to manage controllers

•!   [self.navigationController pushViewController: self.ctr animate:YES]

•!   [self.navigationController popViewControllerAnimate: YES];
File I/O



•!   Your appliction is Sandboxed. Cannot access data from other apps

•!   Documents directory

•!   Tmp directory
Bootstrapping iPhone Development

More Related Content

What's hot

How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
zynamics GmbH
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
jduart
 

What's hot (20)

C++ to java
C++ to javaC++ to java
C++ to java
 
Tutorial c#
Tutorial c#Tutorial c#
Tutorial c#
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
C#
C#C#
C#
 
Rootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applications
 
Java notes
Java notesJava notes
Java notes
 
C sharp
C sharpC sharp
C sharp
 
C#.NET
C#.NETC#.NET
C#.NET
 
Wahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash CourseWahckon[2] - iOS Runtime Hacking Crash Course
Wahckon[2] - iOS Runtime Hacking Crash Course
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming language
 
Introduction to mobile reversing
Introduction to mobile reversingIntroduction to mobile reversing
Introduction to mobile reversing
 
API workshop: Deep dive into Java
API workshop: Deep dive into JavaAPI workshop: Deep dive into Java
API workshop: Deep dive into Java
 
Introduction To Java.
Introduction To Java.Introduction To Java.
Introduction To Java.
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Java
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
Core Java
Core JavaCore Java
Core Java
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
core java
core javacore java
core java
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
 

Viewers also liked (6)

Mobile development
Mobile developmentMobile development
Mobile development
 
01 introduction
01 introduction01 introduction
01 introduction
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile Intro
 
More! @ ED-MEDIA
More! @ ED-MEDIAMore! @ ED-MEDIA
More! @ ED-MEDIA
 
Mume HTML5 Intro
Mume HTML5 IntroMume HTML5 Intro
Mume HTML5 Intro
 
iOS Development Introduction
iOS Development IntroductioniOS Development Introduction
iOS Development Introduction
 

Similar to Bootstrapping iPhone Development

Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
Muhammad Abdullah
 
Intro to Objective C
Intro to Objective CIntro to Objective C
Intro to Objective C
Ashiq Uz Zoha
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
DataArt
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
juliasceasor
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3
Sisir Ghosh
 
Xcode, Basics and Beyond
Xcode, Basics and BeyondXcode, Basics and Beyond
Xcode, Basics and Beyond
rsebbe
 

Similar to Bootstrapping iPhone Development (20)

Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
 
Intro to Objective C
Intro to Objective CIntro to Objective C
Intro to Objective C
 
Никита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-CНикита Корчагин - Programming Apple iOS with Objective-C
Никита Корчагин - Programming Apple iOS with Objective-C
 
Ios development
Ios developmentIos development
Ios development
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
Cappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application FrameworkCappuccino - A Javascript Application Framework
Cappuccino - A Javascript Application Framework
 
Csharp introduction
Csharp introductionCsharp introduction
Csharp introduction
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3
 
Image Processing and Computer Vision in iPhone and iPad
Image Processing and Computer Vision in iPhone and iPadImage Processing and Computer Vision in iPhone and iPad
Image Processing and Computer Vision in iPhone and iPad
 
Comp102 lec 3
Comp102   lec 3Comp102   lec 3
Comp102 lec 3
 
Intro to .NET and Core C#
Intro to .NET and Core C#Intro to .NET and Core C#
Intro to .NET and Core C#
 
C# Fundamental
C# FundamentalC# Fundamental
C# Fundamental
 
Xcode, Basics and Beyond
Xcode, Basics and BeyondXcode, Basics and Beyond
Xcode, Basics and Beyond
 
introduction to c #
introduction to c #introduction to c #
introduction to c #
 
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
CocoaConf DC - Automate with Swift - Tony Ingraldi
CocoaConf DC -  Automate with Swift - Tony IngraldiCocoaConf DC -  Automate with Swift - Tony Ingraldi
CocoaConf DC - Automate with Swift - Tony Ingraldi
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 

More from ThoughtWorks

Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific Languages
ThoughtWorks
 
Ruby 124C41+ - Matz
Ruby 124C41+  - MatzRuby 124C41+  - Matz
Ruby 124C41+ - Matz
ThoughtWorks
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
ThoughtWorks
 
Aman kingrubyoo pnew
Aman kingrubyoo pnew Aman kingrubyoo pnew
Aman kingrubyoo pnew
ThoughtWorks
 

More from ThoughtWorks (20)

Online and Publishing casestudies
Online and Publishing casestudiesOnline and Publishing casestudies
Online and Publishing casestudies
 
Insurecom Case Study
Insurecom Case StudyInsurecom Case Study
Insurecom Case Study
 
Grameen Case Study
Grameen Case StudyGrameen Case Study
Grameen Case Study
 
BFSI Case Sudies
BFSI Case SudiesBFSI Case Sudies
BFSI Case Sudies
 
Construction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific LanguagesConstruction Techniques For Domain Specific Languages
Construction Techniques For Domain Specific Languages
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Concurrency patterns in Ruby
Concurrency patterns in RubyConcurrency patterns in Ruby
Concurrency patterns in Ruby
 
Lets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagiLets build-ruby-app-server: Vineet tyagi
Lets build-ruby-app-server: Vineet tyagi
 
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank... Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
Ruby on Rails versus Django - A newbie Web Developer's Perspective -Shreyank...
 
Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices Nick Sieger-Exploring Rails 3 Through Choices
Nick Sieger-Exploring Rails 3 Through Choices
 
Present and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola biniPresent and Future of Programming Languages - ola bini
Present and Future of Programming Languages - ola bini
 
The ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj KumarThe ruby on rails i18n core api-Neeraj Kumar
The ruby on rails i18n core api-Neeraj Kumar
 
Ruby 124C41+ - Matz
Ruby 124C41+  - MatzRuby 124C41+  - Matz
Ruby 124C41+ - Matz
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. Lim
 
Project Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G SProject Fedena and Why Ruby on Rails - ArvindArvind G S
Project Fedena and Why Ruby on Rails - ArvindArvind G S
 
Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta Glass fish rubyconf-india-2010-Arun gupta
Glass fish rubyconf-india-2010-Arun gupta
 
Aman kingrubyoo pnew
Aman kingrubyoo pnew Aman kingrubyoo pnew
Aman kingrubyoo pnew
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software Framework
 
DSL Construction rith Ruby
DSL Construction rith RubyDSL Construction rith Ruby
DSL Construction rith Ruby
 
Cloud Computing
Cloud  ComputingCloud  Computing
Cloud Computing
 

Recently uploaded

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
Safe Software
 
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
Victor Rentea
 

Recently uploaded (20)

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
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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...
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
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...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
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
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
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
 

Bootstrapping iPhone Development

  • 1. Bootstrapping iPhone Development Munjal Budhabhatti Senior Consultant Sep/24/2009 San Antonio
  • 2. Agenda !!Current state of iPhone Development !!Fast track to Objective – C !!Fast track to XCode and Interface Builder !!Getting productive using OR-Framework, Testing, Serialization
  • 3. Current state of iPhone Development •! Requirements –! Intel based Mac with OSX 10.5 –! iPhone SDK (Sign-up for iPhone Developer Program $99 for a year) –! Do NOT need iPhone or iPod Touch (Work on iPhone Simulator) •! Developer Resources http://developer.apple.com/iphone http://devforums.apple.com http://cs193p.stanford.edu
  • 4. Fast track to Objective – C •! Object oriented programming language to write Applications for iPhone and Mac OS •! Powerful set of extensions to the standard ANSI C language –! Object oriented –! Dynamic (Adds Smalltalk-style or Ruby-style messaging) •! You manage your memory – Probably a good thing in mobile devices
  • 5. Objective – C Syntax •! Objective – C is a strict superset thin layer on top of ANSI C •! Compile any ANSI C program with Objective – C compiler •! Object syntax derived from Smalltalk •! Non object oriented syntax identical to C •! A bit clumsy syntax. Can get lost in the woods. Do NOT let the syntax defeat you.
  • 6. Coding in Objective – C •! Classes are developed using a header and an implementation. •! Names and types of instance variables and method signature in header file. Implement methods in implementation file Interface Implementation @interface classname : superclassname { @implementation classname //instance variables + classMethod1 { } } +classMethod1; + (returnType) classMethod2 { +(returnType) classMethod2; } -instanceMethod1; - instanceMethod1 { -(returnType) instanceMethod2; } @end - (returnType) instanceMethod2 { }
  • 7. Messages (Methods) in Objective – C •! Java and C# implements Simula-style programming model: a method is bound to section of code in a compiler •! Objective – C is based on sending messages to object instances. Message is simply a name, resolved at runtime by the receiving object. •! fullName = [firstName stringByAppendingString: lastName] •! No type-checking. If the object cannot respond to a message it simply ignores it. No NULL checking!! Yay!!
  • 8. Static and Dynamic Typing Objective – C •! Static typing using NSObject – the mother of almost all objects. You can have objects that don’t derive from NSObject. •! Dynamic typing using id –! Sending messages to Nil is OK –! Dynamic objection creation: objc_getClass, class_createInstance, class_getInstanceMethod, class_getInstanceVariable –! TypeIntrospection : isMemberOfClass & isKindOfClass
  • 9. Invocation and Memory Management in Objective – C •! Memory management possible using Garbage collector for Mac OS •! You manage your memory for iPhone OS •! LeanManager *ronCampbell = [[LeanManager alloc] init];
  • 10. Protocols in Objective – C •! Supports multiple-inheritance of specification •! Similar to Interface in C# and Java. However, the methods could be optional. •! Used to declare methods that could be implemented by any class •! Used to declare interface to an object while concealing its class •! Used to capture similarities among classes that are not in hierarchy
  • 11. Protocol Example in Objective – C @protocol Serialization @interface AccountImage : Image <Serialization> - (void) serialize; - (void) serialize; - (void) deserialize; - (void) deserialize; @end @end
  • 12. Forwarding in Objective – C •! Dynamic nature of Objective C allows forwarding of messages •! If an object doesn’t respond to a message, it can forward to one that probably could. •! Similar to method_missing in Ruby •! ages = [persons age]
  • 13. Category in Objective – C •! A category allows you to add methods to an existing class – even for ones that you don’t own or have the source code •! Allows to extend the functionality without subclassing •! Split the implementation of your class between several files •! Caveat: Cannot create new instance variable in a class
  • 14. Fast track to Interface Builder •! App for iPhone devs to create GUI •! Typical MVC pattern. Write models and controllers in Xcode. Build interface in Interface Builder •! One could build interface using code. However, I would advise to bear the pain once and learn using Interface Builder with Xcode. •! Nib file and the magic
  • 15. Fast Track to OR-framework such as Active Record •! Beautify your models –! Will you make raw SQL calls ? •! Start using ObjectPersistentFramework
  • 16. Fast track to Testing •! Test using GoogleToolbox •! Mock using OCMock •! Serialization using JSON framework for iPhone
  • 17. iPhone development fundamentals •! Cocoa Touch – Framework to develop touchscreen applications: UI elements, event dispatching, application lifecycle •! Media – Graphics, animations, sound, video •! Core Services – Collections, Strings, Location, SQLLite, Networking •! Core OS Layer – Standard IO/, Power Management
  • 18. main() method •! Java/C# developers look for “main()” method •! NSApplication provides the central framwork for app execution •! Every app creates one instance of NSApplication in main() •! After NSApplication creation, load the Nib file and start event loop •! Nib file loads the UI •! applicationDidFinishLauching() method called when app is launched
  • 19. View Controllers •! Model View Controller Pattern •! Each view in an iPhone app is managed by UIViewController •! Mother of all view classes •! Importance of IBAction and IBOutlet •! IBAction: editButtonClicked() •! IBOutlet: UILabel
  • 20. Table View Controller •! Define and populate NSMutableArray in initWithCoder •! Implement numberOfRowsInSection protocol for tabelView •! Implement cellForRowAtIndexPath •! Improve performance by reusing cells
  • 21. Navigation Controller •! Mail app is the best way to understand navigation controller •! Navigation controller maintains stack of view controllers •! Each controller represents one node in hierarchy •! Typical push and pop to manage controllers •! [self.navigationController pushViewController: self.ctr animate:YES] •! [self.navigationController popViewControllerAnimate: YES];
  • 22. File I/O •! Your appliction is Sandboxed. Cannot access data from other apps •! Documents directory •! Tmp directory