NSURLConnection still calls delegate AFTER cancel method has been called

Posted by Shizam on Stack Overflow See other posts from Stack Overflow or by Shizam
Published on 2010-03-23T21:10:26Z Indexed on 2010/03/23 21:13 UTC
Read the original article Hit count: 456

Filed under:
|
|
|

Hi All, Having a problem with NSURLConnection, if I create a NSURLConnection and call [connection connectionWithRequest] let it load a little then call [connection cancel] most of the time that works fine. However occasionally even after I call [connection cancel] the connection's delegate still gets called (which crashes the app). Googling around it looks like the problem here is a race condition in the runloop, I cancel the connection and release the delegate but before the runloop cycles it calls the delegate functions -> crash.

Is there a way for me to, after I call [connection cancel] confirm the connection has actually canceled? Even a crappy while() loop will do :(

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk