SlideShare une entreprise Scribd logo
1  sur  15
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

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

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

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

Dernier

+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@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+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...
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

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