- Web Services Connection
- #1 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@/"http://maps.google.com/maps/geo?output=json&q= %@” address, nil]]; NSString *data = [[NSString alloc] initWithContentsOfURL:url];
- #2 [NSThread detachNewThreadSelector: @selector(getJSON) toTarget:self withObject:nil];
- #3 NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @”http://www.google.com” ]]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release];
- NSURLConnection - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response; - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; - (void)connectionDidFinishLoading:(NSURLConnection *)connection;
- 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.
- My Approach
- http://github.com/leonho/iphone-libs