NSURLConnection doesn't call delegate methods

Burjua picture Burjua · Jul 23, 2010 · Viewed 12.3k times · Source

I saw similar questions here, but I couldn't find solution to my problem. I have a simple NSURLConnection in main thread (At least I didn't create any other threads), but my delegate methods aren't get called

[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];

and no methods called, e.g.

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"didReceiveResponse");
}

self is also a delegate for NSXMLParser, but I think it should not be a problem, as I have this working in my other class in the same project. I checked everything 10 times already, but can't find any problem.

I've seen some hack to solve it here: http://www.depl0y.com/?p=345 but I don't like it, May be someone knows better solution? thanks

Answer

Michael Kessler picture Michael Kessler · Jul 23, 2010

The only reason I know is a separate thread (that is already terminated when the delegate methods are called).

Try to NSLog(@"Is%@ main thread", ([NSThread isMainThread] ? @"" : @" NOT"));right before the url connection creation