title: connection:willSendRequest:redirectResponse example prject
body: <p>Could anyone provide me with one please?</p>
  
  <p>.h </p>
  
  <pre><code> #import "UntitledViewController.h"
  
   @implementation UntitledViewController
  
  
  
   - (id)init 
   {
  self = [super init];
  if (self) 
  {
      NSURL *url = [NSURL URLWithString:@"http://tinyurl.com/a3cx"];
      [self loadTinyURL:url];
  }
  return self;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>- (void)loadTinyURL:(NSURL *)url 
  {
  NSURLRequest *request = [NSURLRequest requestWithURL:url];
  NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request 
                                                                delegate:self];
  if (!connection) 
      NSLog(@"could not connect with: %@", url);
  else {
      NSLog(@"this works");
  }
  
  }
  
  
    - (NSURLRequest *)connection:(NSURLConnection *)connection 
           willSendRequest:(NSURLRequest *)request 
          redirectResponse:(NSURLResponse *)response
    {
  NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
  int statusCode = [httpResponse statusCode];
  
  // http statuscodes between 300 &amp; 400 is a redirect ...
  if (response &amp;&amp; statusCode &gt;= 300 &amp;&amp; statusCode &lt; 400) 
      NSLog(@"redirecting to : %@", [request URL]);
  
  return request;
  </code></pre>