SlideShare una empresa de Scribd logo
1 de 72
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a iPhone for .NET Developers

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
 

Similar a 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
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
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
 

Último (20)

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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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...
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
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
 

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