I have url connection, which normally works fine
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:delegate];
But when I create a modal window, no request ever receives response:
[NSApp runModalForWindow:window];
If I comment this line out, thus creating a 'standard' window, everything works.
I tried implementing all methods from NSURLConnectionDelegate, not a single of them called.
I suspect this is something about 'run loops', but have little experience in this area. Does anybody have experience in this?
Thank you
If you're targeting 10.5+, you can tell the
NSURLConnection
to also run inNSModalPanelRunLoopMode
(the mode your current thread's runloop would be in while presenting a modal view) viawhere
aRunLoop
would probably be[NSRunLoop currentRunLoop]
and themode
would beNSModalPanelRunLoopMode
. More info in theNSURLConnection
doc.If you're supporting earlier OSs, you may have to get creative (i.e. with multithreading). Good discussion of this issue pre-10.5 here.