Question

As the question says, will the following help? I have not set any delegate to the request. Am I better off setting delegates?

request = nil;
Was it helpful?

Solution

No. NSMutableURLRequest can not 'run'. NSMutableURLRequest is just an object that stores url, body and some other options. To run it you should use NSURLConnection, example:

NSURLConnection* your_connection = [NSURLConnection connectionWithRequest:your_request delegate:delegate];

or NSURLSession which returns NSURLSessionTask, example:

NSURLSessionDownloadTask *sessionTask = [NSURLSession downloadTaskWithRequest:your_request];

To cancel connection/task you should call

[your_connection cancel];

or

[sessionTask cancel];

depending on what do you use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top