Hi Rick,

You can implement the following NSURLSessionTaskDelegate method in order to 
receive progress updates about the upload task while your app is running:

- (void)URLSession:(NSURLSession 
<https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/index.html#//apple_ref/doc/c_ref/NSURLSession>
 *)session
              task:(NSURLSessionTask 
<https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSessionTask_class/index.html#//apple_ref/doc/c_ref/NSURLSessionTask>
 *)task
   didSendBodyData:(int64_t)bytesSent
    totalBytesSent:(int64_t)totalBytesSent
totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend

https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSessionTaskDelegate_protocol/index.html#//apple_ref/occ/intfm/NSURLSessionTaskDelegate/URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:

You can also poll for progress at any times via the countOfBytesSent and 
countOfBytesExpectedToSend properties on NSURLSessionTask. There are equivalent 
properties / delegate methods for download tasks as well.

Hope this helps,
Dan

> On Feb 9, 2015, at 1:08 PM, Rick Mann <[email protected]> wrote:
> 
> I was hoping to switch from the old networking code to using background 
> NSURLSessions for my app's upload task. I wanted to use a single background 
> upload task for uploading when my app is running, and to ensure that it 
> continues to upload in the background if the app is killed.
> 
> But my app displays upload progress, and I don't see any way to get the 
> progress from an upload (or a download, for that matter).
> 
> Do I have to to have the mess of uploading "normally" while my app is 
> running, and then, during app termination, re-establish all my uploads as 
> background uploads to let it keep going? This seems excessively burdensome.
> 
> 
> -- 
> Rick Mann
> [email protected]
> 
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/macnetworkprog/dvinegrad%40apple.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to