Web Services
Connection
#1

            NSURL *url = [NSURL URLWithString:[NSString
stringWithFormat:@quot;http://maps.google.com/maps/geo?output=...
#2


[NSThread detachNewThreadSelector: @selector(getJSON)
            toTarget:self withObject:nil];
#3

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:
[NSURL URLWithString: @”http://www.google.com” ]];

NSURLCo...
NSURLConnection

 - (void)connection:(NSURLConnection *)connection
   didReceiveResponse:(NSURLResponse *)response;

 - (v...
Problem
• Every initialized NSURLConnection shares
  the same delegate methods, unless you
  delegate to different objects...
My Approach
http://github.com/leonho/iphone-libs
Upcoming SlideShare
Loading in …5
×

Using iPhone's NSURLConnection class

20,614 views

Published on

Published in: Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
20,614
On SlideShare
0
From Embeds
0
Number of Embeds
191
Actions
Shares
0
Downloads
65
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using iPhone's NSURLConnection class

  1. 1. Web Services Connection
  2. 2. #1 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@quot;http://maps.google.com/maps/geo?output=json&q= %@” address, nil]]; NSString *data = [[NSString alloc] initWithContentsOfURL:url];
  3. 3. #2 [NSThread detachNewThreadSelector: @selector(getJSON) toTarget:self withObject:nil];
  4. 4. #3 NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @”http://www.google.com” ]]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release];
  5. 5. NSURLConnection - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response; - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; - (void)connectionDidFinishLoading:(NSURLConnection *)connection;
  6. 6. Problem • Every initialized NSURLConnection shares the same delegate methods, unless you delegate to different objects. • You could implement a class for holding all those these, but you need to create a object of that class for every download. Not good.
  7. 7. My Approach
  8. 8. http://github.com/leonho/iphone-libs

×