iphone - Creating and canceling an NSURLConnection -


I have an NSURL connection that is working fine when I allow the load to complete. But if the user hits the back button, which means that the webview will disappear, I want to turn on the NSRR connection. But if the webview call is made in this scene, then the viewwiki is called Dissepier, and then I do: [cancel]

I get an NSINValidArgument exception .

Connection is defined as example data in .h file:

  NSURLConnection * conn;  

Async has been started here:

  NSURLRequest * request = [NSURLRequest request with url: [NSURL URLWithString: articleURL]]; If ([NSUrCon Connection Connection: & Requestable) & amp; Accessible) {// Set an Asynchronous Load Request = [Request with NSR Connection Connection: Request Rep: Auto]; LoadCancelled = NO; If (Kon) {NSLog (@ "Article is RSS !!!!"); Self.articleData = [NSMutableData data]; }}  

You will be the reason for getting the exception that you are saving an autorrietary object For an example variable.
"Cone" will be automatically released automatically when a user clicks back the back button, then you cancel the call. So, you had an exception.
To stop this, you should retain the NSURLConnection object when you put it in an instance variable.

  conn = [[NSURL connection connectionWiki: request representative: self] maintaining];  

or

  conn = [[NSURL connection alloted] initWithRequest: request representative: self];  

Do not forget to release it in the dealloc method.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -