Who calls the methods in logger.m?


#1

Hi,

I do understand, what the individual methods in the logger class do.

I do not understand e.g. :

[code] -(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@“Got It !”);
NSString *string =[[NSString alloc ] initWithData:incomingData
encoding:NSUTF8StringEncoding];
incomingData = nil;

    NSLog(@"Whole size: %lu", [string length]);
    
            NSLog(@"Whole string: %@", string);
}

[/code]

Where is “connectionDidFinishLoading” called in the program and how is the pointer connection handed over to the method ?

[code] //definiere URL
NSURL *url =[NSURL URLWithString:@“http://www.gutenberg.org/cache/epub/205/pg205.txt” ];

    NSURLRequest *request=[NSURLRequest requestWithURL:url];
   
   __unused NSURLConnection *fetchConn = [[NSURLConnection alloc] initWithRequest:request
                                                                                                                 delegate:logger
                                                                                                     startImmediately:YES];

[/code]

Is it like this:

  1. url contains the source for the file
  2. request is defined with the url above and contains a fetch request
  3. fetchConn initializes the Connection with the request defined above and forwards all reponses to the delegate logger, thus invoking the indiviual methods in logger.m ???

That correct ?

Thanks in advance for clarification!

Klaus