SlideShare a Scribd company logo
iPhone for .NET Developers
       Ben Scheirman
       Director of Development - ChaiONE
       @subdigital




Tuesday, September 28, 2010
What you need

           A Mac
           Xcode
           iPhone SDK (limited to Simulator)
           iPhone Developer Program ($99 /year)




Tuesday, September 28, 2010
Objective-C

                Based on C
                Object Oriented
                Dynamic
                A little weird
                Powerful




Tuesday, September 28, 2010
Objective-C Primer
           Calling methods




Tuesday, September 28, 2010
Objective-C Primer
           Calling methods


       [someObject someMethod];




Tuesday, September 28, 2010
Objective-C Primer
           Calling methods


       [someObject someMethod];

       [someObject someMethodWithInput:5];




Tuesday, September 28, 2010
Objective-C Primer
           Calling methods


       [someObject someMethod];

       [someObject someMethodWithInput:5];

       [dictionary setObject:obj
                      forKey:key];


Tuesday, September 28, 2010
Objective-C Primer
           Nesting method calls




Tuesday, September 28, 2010
Objective-C Primer
           Nesting method calls

       [NSString stringWithFormat:
           [prefs format]];




Tuesday, September 28, 2010
Objective-C Primer
           Instantiating classes




Tuesday, September 28, 2010
Objective-C Primer
           Instantiating classes


       UIView *view = [[UIView alloc] init];




Tuesday, September 28, 2010
Objective-C Primer
           Instantiating classes


       UIView *view = [[UIView alloc] init];


       NSDate *date = [NSDate date];




Tuesday, September 28, 2010
Objective-C Primer
           Defining Classes




Tuesday, September 28, 2010
Objective-C Primer
           Defining Classes

        //Person.h
        @interface Person {
          //instance variables
        }

        //properties & methods

        @end


Tuesday, September 28, 2010
Objective-C Primer
           Defining Classes




Tuesday, September 28, 2010
Objective-C Primer
           Defining Classes

        //Person.m
        #import "Person.h"

        @implementation Person

        //implement properties & methods

        @end


Tuesday, September 28, 2010
Objective-C Primer
           Defining Methods




Tuesday, September 28, 2010
Objective-C Primer
           Defining Methods



        -(void)showLoadingText:(NSString *)text animated:(BOOL)animated;




Tuesday, September 28, 2010
Objective-C Primer
           Defining Methods
                                    Method name (selector)




        -(void)showLoadingText:(NSString *)text animated:(BOOL)animated;




Tuesday, September 28, 2010
Objective-C Primer
           Defining Methods
                                    Method name (selector)




        -(void)showLoadingText:(NSString *)text animated:(BOOL)animated;




               Return Type




Tuesday, September 28, 2010
Objective-C Primer
           Defining Methods
                                    Method name (selector)




        -(void)showLoadingText:(NSString *)text animated:(BOOL)animated;




               Return Type


 Instance method

Tuesday, September 28, 2010
Objective-C Primer
           Defining Methods
                                    Method name (selector)




        -(void)showLoadingText:(NSString *)text animated:(BOOL)animated;




               Return Type
                                                  Parameters

 Instance method

Tuesday, September 28, 2010
Memory Management


           No garbage collection on the iPhone
           Retain / Release




Tuesday, September 28, 2010
Memory Management
           Retain / Release Dance




Tuesday, September 28, 2010
Memory Management
           Retain / Release Dance

                                        1
       Foo *foo = [[Foo alloc] init];




Tuesday, September 28, 2010
Memory Management
           Retain / Release Dance

                                        1
       Foo *foo = [[Foo alloc] init];
                                        2
       [foo retain];




Tuesday, September 28, 2010
Memory Management
           Retain / Release Dance

                                        1
       Foo *foo = [[Foo alloc] init];
                                        2
       [foo retain];
                                        1
       [foo release];


Tuesday, September 28, 2010
Memory Management
           Retain / Release Dance

                                        1
       Foo *foo = [[Foo alloc] init];
                                        2
       [foo retain];
                                        1
       [foo release];

       [foo release];                   0

Tuesday, September 28, 2010
Memory Management
           Retain / Release Dance

                                                         1
       Foo *foo = [[Foo alloc] init];
                                                         2
       [foo retain];
                                                         1
       [foo release];

       [foo release];               foo is deallocated   0

Tuesday, September 28, 2010
Getters / Setters




Tuesday, September 28, 2010
Getters / Setters

        [foo setBar:@"baz"];




Tuesday, September 28, 2010
Getters / Setters

        [foo setBar:@"baz"];

        [foo bar]; //returns @"baz"




Tuesday, September 28, 2010
Getters / Setters

        [foo setBar:@"baz"];

        [foo bar]; //returns @"baz"


        foo.bar = @"gruul";



Tuesday, September 28, 2010
Getters / Setters

        [foo setBar:@"baz"];

        [foo bar]; //returns @"baz"


        foo.bar = @"gruul";

        foo.bar //returns @"gruul"
Tuesday, September 28, 2010
Implementing setters




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {
         [bar release];




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {
         [bar release];
         bar = nil;




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {
         [bar release];
         bar = nil;
       }




Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {
         [bar release];
         bar = nil;
       }
       if(value != nil)



Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {
         [bar release];
         bar = nil;
       }
       if(value != nil)
         bar = [value retain];

Tuesday, September 28, 2010
Implementing setters
     -(void)setBar:(id)value {
       if(bar == value) return;
       if(bar != nil) {
         [bar release];
         bar = nil;
       }
       if(value != nil)
         bar = [value retain];
     }
Tuesday, September 28, 2010
No Thanks




Tuesday, September 28, 2010
Properties




Tuesday, September 28, 2010
Properties
     //Foo.h




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m
     @synthesize image, message;




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m
     @synthesize image, message;

     -(void)dealloc {




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m
     @synthesize image, message;

     -(void)dealloc {

        [image release];




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m
     @synthesize image, message;

     -(void)dealloc {

        [image release];
        [message release];




Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m
     @synthesize image, message;

     -(void)dealloc {

        [image release];
        [message release];

        [super dealloc];



Tuesday, September 28, 2010
Properties
     //Foo.h
     @property (nonatomic, retain) UIImage *image;
     @property (nonatomic, copy) NSString *message;




     //Foo.m
     @synthesize image, message;

     -(void)dealloc {

         [image release];
         [message release];

         [super dealloc];
     }


Tuesday, September 28, 2010
Dot Syntax Dogma


                                Use dot syntax if you like it

                              Just be aware of what it's hiding




Tuesday, September 28, 2010
Xcode

           Your IDE
           Code completion
           Interactive Debugger


           Lacks good refactoring tools




Tuesday, September 28, 2010
Interface Builder


           Drag-n-drop UI building
           Layouts are defined in XIBs (XML representation).
           Usually called "Nibs"


           "Make connections" with classes defined in Xcode
                variables --> UI components
                UI events --> methods
Tuesday, September 28, 2010
Instruments


           Find Memory Leaks
           Analyze Memory Usage
           Track down slow code




Tuesday, September 28, 2010
iOS SDK
                                       Accelerate     CoreMotion

                                      AddressBook    CoreTelephony

                                      AudioToolbox     CoreText
              Your app
                                      AVFoundation    CoreVideo

                              UIKit    CoreAudio       GameKit

                   CoreFoundation      CoreData           iAd

                     CoreGraphics     CoreLocation      MapKit

                                       CFNetwork        StoreKit



Tuesday, September 28, 2010
Model View Controller


                              Model                View




                                      Controller



Tuesday, September 28, 2010
The View Controller

           Handles setup logic for a screen
           Handles user input
           Interacts with the model
           Contains 1 or more views




Tuesday, September 28, 2010
The View

           Visual representation
           Drawing
           Laying out subviews (autorotation)
           May Handle touch events




Tuesday, September 28, 2010
Lifecycle of an App

                main.m




Tuesday, September 28, 2010
Lifecycle of an App

                main.m




           UIApplication




Tuesday, September 28, 2010
Lifecycle of an App

                main.m




           UIApplication




Tuesday, September 28, 2010
Lifecycle of an App

                main.m        MainWindow.xib




           UIApplication




Tuesday, September 28, 2010
Lifecycle of an App

                main.m        MainWindow.xib




           UIApplication




Tuesday, September 28, 2010
Lifecycle of an App

                main.m        MainWindow.xib




           UIApplication                         YourAppDelegate



                                               UIWindow   Root View Controller




Tuesday, September 28, 2010
Lifecycle of an App

                main.m                 MainWindow.xib




           UIApplication                                        YourAppDelegate
                              applicationDidFinishLaunching




                                                              UIWindow   Root View Controller




Tuesday, September 28, 2010
Time to code!




Tuesday, September 28, 2010

More Related Content

Similar to iPhone for .NET Developers

Mongo db
Mongo dbMongo db
Mongo db
Antonio Terreno
 
Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)
jan_mindmatters
 
Objective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET DevelopersObjective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET Developers
Ben Scheirman
 
Continuous Integration Testing for Plone Using Hudson
Continuous Integration Testing for Plone Using HudsonContinuous Integration Testing for Plone Using Hudson
Continuous Integration Testing for Plone Using Hudson
Eric Steele
 
Help implement BST- The code must follow the instruction below as well.pdf
Help implement BST- The code must follow the instruction below as well.pdfHelp implement BST- The code must follow the instruction below as well.pdf
Help implement BST- The code must follow the instruction below as well.pdf
a2zmobiles
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
Santiago Pastorino
 

Similar to iPhone for .NET Developers (6)

Mongo db
Mongo dbMongo db
Mongo db
 
Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)Mongodb on Ruby And Rails (froscon 2010)
Mongodb on Ruby And Rails (froscon 2010)
 
Objective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET DevelopersObjective-C & iPhone for .NET Developers
Objective-C & iPhone for .NET Developers
 
Continuous Integration Testing for Plone Using Hudson
Continuous Integration Testing for Plone Using HudsonContinuous Integration Testing for Plone Using Hudson
Continuous Integration Testing for Plone Using Hudson
 
Help implement BST- The code must follow the instruction below as well.pdf
Help implement BST- The code must follow the instruction below as well.pdfHelp implement BST- The code must follow the instruction below as well.pdf
Help implement BST- The code must follow the instruction below as well.pdf
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 

Recently uploaded

Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
saastr
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 

Recently uploaded (20)

Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
9 CEO's who hit $100m ARR Share Their Top Growth Tactics Nathan Latka, Founde...
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 

iPhone for .NET Developers

  • 1. iPhone for .NET Developers Ben Scheirman Director of Development - ChaiONE @subdigital Tuesday, September 28, 2010
  • 2. What you need A Mac Xcode iPhone SDK (limited to Simulator) iPhone Developer Program ($99 /year) Tuesday, September 28, 2010
  • 3. Objective-C Based on C Object Oriented Dynamic A little weird Powerful Tuesday, September 28, 2010
  • 4. Objective-C Primer Calling methods Tuesday, September 28, 2010
  • 5. Objective-C Primer Calling methods [someObject someMethod]; Tuesday, September 28, 2010
  • 6. Objective-C Primer Calling methods [someObject someMethod]; [someObject someMethodWithInput:5]; Tuesday, September 28, 2010
  • 7. Objective-C Primer Calling methods [someObject someMethod]; [someObject someMethodWithInput:5]; [dictionary setObject:obj forKey:key]; Tuesday, September 28, 2010
  • 8. Objective-C Primer Nesting method calls Tuesday, September 28, 2010
  • 9. Objective-C Primer Nesting method calls [NSString stringWithFormat: [prefs format]]; Tuesday, September 28, 2010
  • 10. Objective-C Primer Instantiating classes Tuesday, September 28, 2010
  • 11. Objective-C Primer Instantiating classes UIView *view = [[UIView alloc] init]; Tuesday, September 28, 2010
  • 12. Objective-C Primer Instantiating classes UIView *view = [[UIView alloc] init]; NSDate *date = [NSDate date]; Tuesday, September 28, 2010
  • 13. Objective-C Primer Defining Classes Tuesday, September 28, 2010
  • 14. Objective-C Primer Defining Classes //Person.h @interface Person { //instance variables } //properties & methods @end Tuesday, September 28, 2010
  • 15. Objective-C Primer Defining Classes Tuesday, September 28, 2010
  • 16. Objective-C Primer Defining Classes //Person.m #import "Person.h" @implementation Person //implement properties & methods @end Tuesday, September 28, 2010
  • 17. Objective-C Primer Defining Methods Tuesday, September 28, 2010
  • 18. Objective-C Primer Defining Methods -(void)showLoadingText:(NSString *)text animated:(BOOL)animated; Tuesday, September 28, 2010
  • 19. Objective-C Primer Defining Methods Method name (selector) -(void)showLoadingText:(NSString *)text animated:(BOOL)animated; Tuesday, September 28, 2010
  • 20. Objective-C Primer Defining Methods Method name (selector) -(void)showLoadingText:(NSString *)text animated:(BOOL)animated; Return Type Tuesday, September 28, 2010
  • 21. Objective-C Primer Defining Methods Method name (selector) -(void)showLoadingText:(NSString *)text animated:(BOOL)animated; Return Type Instance method Tuesday, September 28, 2010
  • 22. Objective-C Primer Defining Methods Method name (selector) -(void)showLoadingText:(NSString *)text animated:(BOOL)animated; Return Type Parameters Instance method Tuesday, September 28, 2010
  • 23. Memory Management No garbage collection on the iPhone Retain / Release Tuesday, September 28, 2010
  • 24. Memory Management Retain / Release Dance Tuesday, September 28, 2010
  • 25. Memory Management Retain / Release Dance 1 Foo *foo = [[Foo alloc] init]; Tuesday, September 28, 2010
  • 26. Memory Management Retain / Release Dance 1 Foo *foo = [[Foo alloc] init]; 2 [foo retain]; Tuesday, September 28, 2010
  • 27. Memory Management Retain / Release Dance 1 Foo *foo = [[Foo alloc] init]; 2 [foo retain]; 1 [foo release]; Tuesday, September 28, 2010
  • 28. Memory Management Retain / Release Dance 1 Foo *foo = [[Foo alloc] init]; 2 [foo retain]; 1 [foo release]; [foo release]; 0 Tuesday, September 28, 2010
  • 29. Memory Management Retain / Release Dance 1 Foo *foo = [[Foo alloc] init]; 2 [foo retain]; 1 [foo release]; [foo release]; foo is deallocated 0 Tuesday, September 28, 2010
  • 30. Getters / Setters Tuesday, September 28, 2010
  • 31. Getters / Setters [foo setBar:@"baz"]; Tuesday, September 28, 2010
  • 32. Getters / Setters [foo setBar:@"baz"]; [foo bar]; //returns @"baz" Tuesday, September 28, 2010
  • 33. Getters / Setters [foo setBar:@"baz"]; [foo bar]; //returns @"baz" foo.bar = @"gruul"; Tuesday, September 28, 2010
  • 34. Getters / Setters [foo setBar:@"baz"]; [foo bar]; //returns @"baz" foo.bar = @"gruul"; foo.bar //returns @"gruul" Tuesday, September 28, 2010
  • 36. Implementing setters -(void)setBar:(id)value { Tuesday, September 28, 2010
  • 37. Implementing setters -(void)setBar:(id)value { if(bar == value) return; Tuesday, September 28, 2010
  • 38. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { Tuesday, September 28, 2010
  • 39. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { [bar release]; Tuesday, September 28, 2010
  • 40. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { [bar release]; bar = nil; Tuesday, September 28, 2010
  • 41. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { [bar release]; bar = nil; } Tuesday, September 28, 2010
  • 42. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { [bar release]; bar = nil; } if(value != nil) Tuesday, September 28, 2010
  • 43. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { [bar release]; bar = nil; } if(value != nil) bar = [value retain]; Tuesday, September 28, 2010
  • 44. Implementing setters -(void)setBar:(id)value { if(bar == value) return; if(bar != nil) { [bar release]; bar = nil; } if(value != nil) bar = [value retain]; } Tuesday, September 28, 2010
  • 47. Properties //Foo.h Tuesday, September 28, 2010
  • 48. Properties //Foo.h @property (nonatomic, retain) UIImage *image; Tuesday, September 28, 2010
  • 49. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; Tuesday, September 28, 2010
  • 50. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m Tuesday, September 28, 2010
  • 51. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m @synthesize image, message; Tuesday, September 28, 2010
  • 52. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m @synthesize image, message; -(void)dealloc { Tuesday, September 28, 2010
  • 53. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m @synthesize image, message; -(void)dealloc { [image release]; Tuesday, September 28, 2010
  • 54. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m @synthesize image, message; -(void)dealloc { [image release]; [message release]; Tuesday, September 28, 2010
  • 55. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m @synthesize image, message; -(void)dealloc { [image release]; [message release]; [super dealloc]; Tuesday, September 28, 2010
  • 56. Properties //Foo.h @property (nonatomic, retain) UIImage *image; @property (nonatomic, copy) NSString *message; //Foo.m @synthesize image, message; -(void)dealloc { [image release]; [message release]; [super dealloc]; } Tuesday, September 28, 2010
  • 57. Dot Syntax Dogma Use dot syntax if you like it Just be aware of what it's hiding Tuesday, September 28, 2010
  • 58. Xcode Your IDE Code completion Interactive Debugger Lacks good refactoring tools Tuesday, September 28, 2010
  • 59. Interface Builder Drag-n-drop UI building Layouts are defined in XIBs (XML representation). Usually called "Nibs" "Make connections" with classes defined in Xcode variables --> UI components UI events --> methods Tuesday, September 28, 2010
  • 60. Instruments Find Memory Leaks Analyze Memory Usage Track down slow code Tuesday, September 28, 2010
  • 61. iOS SDK Accelerate CoreMotion AddressBook CoreTelephony AudioToolbox CoreText Your app AVFoundation CoreVideo UIKit CoreAudio GameKit CoreFoundation CoreData iAd CoreGraphics CoreLocation MapKit CFNetwork StoreKit Tuesday, September 28, 2010
  • 62. Model View Controller Model View Controller Tuesday, September 28, 2010
  • 63. The View Controller Handles setup logic for a screen Handles user input Interacts with the model Contains 1 or more views Tuesday, September 28, 2010
  • 64. The View Visual representation Drawing Laying out subviews (autorotation) May Handle touch events Tuesday, September 28, 2010
  • 65. Lifecycle of an App main.m Tuesday, September 28, 2010
  • 66. Lifecycle of an App main.m UIApplication Tuesday, September 28, 2010
  • 67. Lifecycle of an App main.m UIApplication Tuesday, September 28, 2010
  • 68. Lifecycle of an App main.m MainWindow.xib UIApplication Tuesday, September 28, 2010
  • 69. Lifecycle of an App main.m MainWindow.xib UIApplication Tuesday, September 28, 2010
  • 70. Lifecycle of an App main.m MainWindow.xib UIApplication YourAppDelegate UIWindow Root View Controller Tuesday, September 28, 2010
  • 71. Lifecycle of an App main.m MainWindow.xib UIApplication YourAppDelegate applicationDidFinishLaunching UIWindow Root View Controller Tuesday, September 28, 2010
  • 72. Time to code! Tuesday, September 28, 2010