SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
Objective-C
Classes, Protocols, Delegates
      for iOS Beginners




                    Adam Musial-Bright, @a_life_hacker
Classes & Objects


Objective-C is an object oriented language -
this is good, because you can model things.
Modeling the world
Like an architect creates a plan for a house ...




                     http://www.freedigitalphotos.net



... you create a plan for your software.
So plan with classes
A class for ...
                      Roof
                                                   Window
             Wall


                                                  Door
             House     http://www.freedigitalphotos.net


                     Basement
Now translated to iOS
 Window        Door            Basement

          ... could be a ...


 NSView     NSButton           NSString
Class example
The interface and the implementation come always as a pair.
  #import <Foundation/Foundation.h>          #import "Window.h"

  @interface Window : NSObject               @interface Window()
                                             @property NSString *state;
  - (void)open;                              @end

  - (void)close;                             @implementation Window

  - (BOOL)isOpen;                            @synthesize state = _state;

  - (UIImage *)image;                        - (id)init {
                                                 if (self = [super init]) {
  @end                                               self.state = @"closed";
                                                     return self;
                                                 } else {
                                                     return nil;
                                                 }
                                             }

                                                     - (void)open {
                                                         self.state = @"open";
                                                     }
                    http://www.freedigitalphotos.net ...
Classes and Objects
#import <Foundation/Foundation.h>                    #import "Window.h"

@interface Window : NSObject                         @interface Window()
                                                     @property NSString *state;
- (void)open;                                        @end

- (void)close;                                       @implementation Window

- (BOOL)isOpen;                                      @synthesize state = _state;

- (UIImage *)image;                 - (id)init {
                                        if (self = [super init]) {
@end                                        self.state = @"closed";
                                                       two independent
                                            return self;
       Window *northWindow = [[Window alloc] init];
                                        } else {
                                                                                            objects
       Window *southWindow = [[Window alloc] init];
                                            return nil;
                                        }
       [northWindow open];      open the north window
                                    }
       [northWindow isOpen]; // -> open
                                    - (void)open {
       [southWindow isOpen]; // -> closed     the south window
                                        self.state = @"open";
                                                                                    stays closed
                                    }

                                                     ...
                                                                 The interface and the
                  http://www.freedigitalphotos.net         implementation come always as pair.
Class syntax & semantics
#import “MyImportedLibraryHeader.h”           #import "MyClassName.h"

@interface MyClassName : SuperClass           @interface MyClassName()
                                              // private interface
+ (void)classMethod;                          @end

- (void)instenceMethod;                       @implementation MyClassName

- (NSString *)methodWithReturnValue;          - (id)init {
                                                  if (self = [super init]) {
- (void)methodWithParameter:(NSString *)text;         // do some stuff here
                                                      return self;
@end                                              } else {
                                                      return nil;
                                                  }
                                              }

                                              - (void)instanceMethod {
                                                  NSLog(@”log output”);
                                              }

                                              ...

                                              @end
Class take-away #1
#import <Foundation/Foundation.h>   #import "Window.h"     private interface are only
                                                         visible in the implementation
@interface Window : NSObject        @interface Window()
                                    @property NSString *state;
- (void)open;                       @end

- (void)close;                      @implementation Window      synthesize properties
- (BOOL)isOpen;                     @synthesize state = _state;

- (UIImage *)image;                 - (id)init {
                                        if (self = [super init]) {
@end                                        self.state = @"closed";
the interface defines public                 return self;
  methods like “open”, or               } else {          prepare the object state
                                            return nil;
   “close” the window                   }
                                                               when initialized
                                    }

                                    - (void)open {
                                        self.state = @"open";
                                    }
                                            access properties easily
                                    ...
                                              with the “.” notation
Class take-away #2




     connect view elements
    with controller objects to
             outlets
Delegate & Protocol
                           Do not call me all the time...
                                            ...I call you back
                                           when I am ready!

                                   There are moments
                                   where we want an
                                    objects to send a
                                    message to us - a
http://www.freedigitalphotos.net
                                        callback.         http://www.freedigitalphotos.net
Define a protocol
                                    the protocol defines the
#import <Foundation/Foundation.h>
                                        callback method
@protocol NoiseDelegate <NSObject>       “makeNoise”
@required
- (void)makesNoise:(NSString *)noise;
@end
                                             @implementation Window
@interface Window : NSObject {
                                             @synthesize delegate = _delegate;
    id <NoiseDelegate> delegate;
}
                          here we have a     ...            synthesize and execute your
@property id delegate;    delegate and a                       “makeNoise” callback
                                             - (void)close {
                                                 self.state = @"closed";
- (void)open;            delegate property       int r = arc4random() % 4;
                                                 if (r == 0) {
- (void)close;
                                                     [self.delegate makesNoise:@"bang!"];
                                                 } else {
- (BOOL)isOpen;
                                                     [self.delegate makesNoise:@""];
                                                 }
- (UIImage *)image;
                                             }
@end
                                             ...         25% of closed windows
                                                          make a “bang!” noise
Use the delegate
       ... and make some noise when the window is closed.
#import <UIKit/UIKit.h>
#import "Window.h"

@interface HouseViewController :             @implementation HouseViewController
UIViewController <NoiseDelegate> {
                                             ...
   IBOutlet   UIButton *northWindowButton;
   IBOutlet   UIButton *southWindowButton;   [self.northWindow setDelegate:self];
   IBOutlet   UIImageView *northImageView;   [self.southWindow setDelegate:self];
   IBOutlet   UIImageView *southImageView;

}
   IBOutlet   UILabel *noiseLabel;                    set the house controller as a
@end                                                        window delegate
       use the delegate in the class         ...

       interface where the callback
            should be executed
                                             - (void)makesNoise:(NSString *)noise {
                                                 noiseLabel.text = noise;
                                             }
                                                    implement the callback required
                                             ...
                                                           by the delegate
Protocol take-away
               ... send a asynchronous HTTP request ...
@implementation WebService : NSObject

- (void)sendRequest {
     NSURL *url = [NSURL URLWithString:@"http://www.google.com"];

      NSURLRequest *urlRequest = [NSURLRequest
         requestWithURL:url
         cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
         timeoutInterval:30];

       NSURLConnection *connection = [[NSURLConnection alloc]
          initWithRequest:urlRequest delegate:controller];
      ...
}                                                       set a delegate to receive a
- (void)connection:(NSURLConnection *)connection
                                                      response, connection error or
    didReceiveResponse:(NSURLResponse *)response {               timeouts
    ...
}

...
Presentation
  http://www.slideshare.net/musial-bright




  Code
  https://github.com/musial-bright/iOSBeginners




Thank you + Q&A
                           Adam Musial-Bright, @a_life_hacker

Más contenido relacionado

La actualidad más candente

Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
Adieu
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, Lambda
Jussi Pohjolainen
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
cymbron
 

La actualidad más candente (20)

Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
Day 1
Day 1Day 1
Day 1
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Testable Javascript
Testable JavascriptTestable Javascript
Testable Javascript
 
iOS Session-2
iOS Session-2iOS Session-2
iOS Session-2
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere Stockholm
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community conf
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
 
C# Delegates, Events, Lambda
C# Delegates, Events, LambdaC# Delegates, Events, Lambda
C# Delegates, Events, Lambda
 
Week 06 Modular Javascript_Brandon, S. H. Wu
Week 06 Modular Javascript_Brandon, S. H. WuWeek 06 Modular Javascript_Brandon, S. H. Wu
Week 06 Modular Javascript_Brandon, S. H. Wu
 
My Favourite 10 Things about Xcode/ObjectiveC
My Favourite 10 Things about Xcode/ObjectiveCMy Favourite 10 Things about Xcode/ObjectiveC
My Favourite 10 Things about Xcode/ObjectiveC
 
Understanding JavaScript
Understanding JavaScriptUnderstanding JavaScript
Understanding JavaScript
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
 
Operator overload rr
Operator overload  rrOperator overload  rr
Operator overload rr
 
Unbundling the JavaScript module bundler - DevIT
Unbundling the JavaScript module bundler - DevITUnbundling the JavaScript module bundler - DevIT
Unbundling the JavaScript module bundler - DevIT
 

Similar a Objective-C for Beginners

Javaoneconcurrencygotchas 090610192215 Phpapp02
Javaoneconcurrencygotchas 090610192215 Phpapp02Javaoneconcurrencygotchas 090610192215 Phpapp02
Javaoneconcurrencygotchas 090610192215 Phpapp02
Tarun Kumar
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
Whymca
 
Javascript basic course
Javascript basic courseJavascript basic course
Javascript basic course
Tran Khoa
 

Similar a Objective-C for Beginners (20)

Iphone course 1
Iphone course 1Iphone course 1
Iphone course 1
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
 
Javaoneconcurrencygotchas 090610192215 Phpapp02
Javaoneconcurrencygotchas 090610192215 Phpapp02Javaoneconcurrencygotchas 090610192215 Phpapp02
Javaoneconcurrencygotchas 090610192215 Phpapp02
 
連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」連邦の白いヤツ 「Objective-C」
連邦の白いヤツ 「Objective-C」
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
 
Beginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCABeginning icloud development - Cesare Rocchi - WhyMCA
Beginning icloud development - Cesare Rocchi - WhyMCA
 
Javascript
JavascriptJavascript
Javascript
 
Designing for Windows Phone 8
Designing for Windows Phone 8Designing for Windows Phone 8
Designing for Windows Phone 8
 
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Lecture 6, c++(complete reference,herbet sheidt)chapter-16Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
 
Javascript basic course
Javascript basic courseJavascript basic course
Javascript basic course
 
6976.ppt
6976.ppt6976.ppt
6976.ppt
 
Lombok Features
Lombok FeaturesLombok Features
Lombok Features
 
05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards05 JavaScript #burningkeyboards
05 JavaScript #burningkeyboards
 
JavaScript Closures for Dummies & JavaScript prototype, closures and OOP.
JavaScript Closures for Dummies & JavaScript prototype, closures and OOP.JavaScript Closures for Dummies & JavaScript prototype, closures and OOP.
JavaScript Closures for Dummies & JavaScript prototype, closures and OOP.
 
Titanium mobile
Titanium mobileTitanium mobile
Titanium mobile
 

Último

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

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
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
 
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)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Objective-C for Beginners

  • 1. Objective-C Classes, Protocols, Delegates for iOS Beginners Adam Musial-Bright, @a_life_hacker
  • 2. Classes & Objects Objective-C is an object oriented language - this is good, because you can model things.
  • 3. Modeling the world Like an architect creates a plan for a house ... http://www.freedigitalphotos.net ... you create a plan for your software.
  • 4. So plan with classes A class for ... Roof Window Wall Door House http://www.freedigitalphotos.net Basement
  • 5. Now translated to iOS Window Door Basement ... could be a ... NSView NSButton NSString
  • 6. Class example The interface and the implementation come always as a pair. #import <Foundation/Foundation.h> #import "Window.h" @interface Window : NSObject @interface Window() @property NSString *state; - (void)open; @end - (void)close; @implementation Window - (BOOL)isOpen; @synthesize state = _state; - (UIImage *)image; - (id)init { if (self = [super init]) { @end self.state = @"closed"; return self; } else { return nil; } } - (void)open { self.state = @"open"; } http://www.freedigitalphotos.net ...
  • 7. Classes and Objects #import <Foundation/Foundation.h> #import "Window.h" @interface Window : NSObject @interface Window() @property NSString *state; - (void)open; @end - (void)close; @implementation Window - (BOOL)isOpen; @synthesize state = _state; - (UIImage *)image; - (id)init { if (self = [super init]) { @end self.state = @"closed"; two independent return self; Window *northWindow = [[Window alloc] init]; } else { objects Window *southWindow = [[Window alloc] init]; return nil; } [northWindow open]; open the north window } [northWindow isOpen]; // -> open - (void)open { [southWindow isOpen]; // -> closed the south window self.state = @"open"; stays closed } ... The interface and the http://www.freedigitalphotos.net implementation come always as pair.
  • 8. Class syntax & semantics #import “MyImportedLibraryHeader.h” #import "MyClassName.h" @interface MyClassName : SuperClass @interface MyClassName() // private interface + (void)classMethod; @end - (void)instenceMethod; @implementation MyClassName - (NSString *)methodWithReturnValue; - (id)init { if (self = [super init]) { - (void)methodWithParameter:(NSString *)text; // do some stuff here return self; @end } else { return nil; } } - (void)instanceMethod { NSLog(@”log output”); } ... @end
  • 9. Class take-away #1 #import <Foundation/Foundation.h> #import "Window.h" private interface are only visible in the implementation @interface Window : NSObject @interface Window() @property NSString *state; - (void)open; @end - (void)close; @implementation Window synthesize properties - (BOOL)isOpen; @synthesize state = _state; - (UIImage *)image; - (id)init { if (self = [super init]) { @end self.state = @"closed"; the interface defines public return self; methods like “open”, or } else { prepare the object state return nil; “close” the window } when initialized } - (void)open { self.state = @"open"; } access properties easily ... with the “.” notation
  • 10. Class take-away #2 connect view elements with controller objects to outlets
  • 11. Delegate & Protocol Do not call me all the time... ...I call you back when I am ready! There are moments where we want an objects to send a message to us - a http://www.freedigitalphotos.net callback. http://www.freedigitalphotos.net
  • 12. Define a protocol the protocol defines the #import <Foundation/Foundation.h> callback method @protocol NoiseDelegate <NSObject> “makeNoise” @required - (void)makesNoise:(NSString *)noise; @end @implementation Window @interface Window : NSObject { @synthesize delegate = _delegate; id <NoiseDelegate> delegate; } here we have a ... synthesize and execute your @property id delegate; delegate and a “makeNoise” callback - (void)close { self.state = @"closed"; - (void)open; delegate property int r = arc4random() % 4; if (r == 0) { - (void)close; [self.delegate makesNoise:@"bang!"]; } else { - (BOOL)isOpen; [self.delegate makesNoise:@""]; } - (UIImage *)image; } @end ... 25% of closed windows make a “bang!” noise
  • 13. Use the delegate ... and make some noise when the window is closed. #import <UIKit/UIKit.h> #import "Window.h" @interface HouseViewController : @implementation HouseViewController UIViewController <NoiseDelegate> { ... IBOutlet UIButton *northWindowButton; IBOutlet UIButton *southWindowButton; [self.northWindow setDelegate:self]; IBOutlet UIImageView *northImageView; [self.southWindow setDelegate:self]; IBOutlet UIImageView *southImageView; } IBOutlet UILabel *noiseLabel; set the house controller as a @end window delegate use the delegate in the class ... interface where the callback should be executed - (void)makesNoise:(NSString *)noise { noiseLabel.text = noise; } implement the callback required ... by the delegate
  • 14. Protocol take-away ... send a asynchronous HTTP request ... @implementation WebService : NSObject - (void)sendRequest { NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:controller]; ... } set a delegate to receive a - (void)connection:(NSURLConnection *)connection response, connection error or didReceiveResponse:(NSURLResponse *)response { timeouts ... } ...
  • 15. Presentation http://www.slideshare.net/musial-bright Code https://github.com/musial-bright/iOSBeginners Thank you + Q&A Adam Musial-Bright, @a_life_hacker