简体   繁体   中英

iphone - Sending data to server and using NSOperationQueue

In my application, i've to send lots of reports to server. So I created a class SendReport which extends from NSOperation.

Now I in my view controller class I will create NSOperationQueue and then create multiple objects and add them to the queue.

Now in the SendReport, in "main" i want to create NSMutableURLRequest and NSURLConnection and initiate sending data to server...... also i want to implement delegates for NSURLConnection to observer data transfer and when it is finished.....

can someone guide me how should i implement "SendReport" class that will transfer data to server and also to implement delegates please?

Based on what you've written, you're making this process more convoluted then it needs to be. If you are sending files from a background thread then there is no need to send them asynchronously. Just send them synchronously and you can avoid worrying about delegates and callbacks. If you are going to use NSURLConnection to send the files asynchronously, then there is no need to mess around with an operation queue, just start the files sending from the main thread and use the delegate callbacks to update progress in your UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM