kailoon
kailoon

Reputation: 2069

NSURLConnection does not call delegate connection:willSendRequest:redirectResponse:

I am trying to detect an http response code of 302. This is my request line:

urlConnection = [[NSURLConnection connectionWithRequest:request delegate:response] retain];

The response variable is an instance of a class I created which implements:

- (NSURLRequest *)connection:(NSURLConnection *)inConnection: 
             willSendRequest:(NSURLRequest *)inRequest 
            redirectResponse:(NSURLResponse *)inRedirectResponse 
{
    NSLog(@"redirect");
    return inRequest;
}

But for some reason this is not being hit. I'm 100% sure the service call is being hit and is returning a 302. Is there something else I am missing not written in the documentation in order to get this delegate called?

Upvotes: 1

Views: 554

Answers (1)

jtbandes
jtbandes

Reputation: 118651

You've got an extra colon:

 ...(NSURLConnection *)inConnection: willSend...

Remove that and you should be good to go.

(Remember, colons are part of method names; you have to get them exactly right!)

Upvotes: 2

Related Questions