-1

I want to implement Progress view for File Uploading to the server, can any one guide me with example

if i use

- (void)connection:(NSURLConnection *)connection   
   didSendBodyData:(NSInteger)bytesWritten
 totalBytesWritten:(NSInteger)totalBytesWritten
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite    {

    float progress = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
    float total = [[NSNumber numberWithInteger: totalBytesExpectedToWrite] floatValue];
    NSLog(@"progress/total %f",progress/total);
}

it is not called while upload

Buntylm
  • 7,345
  • 1
  • 31
  • 51
Velu Loganathan
  • 241
  • 2
  • 11

1 Answers1

2

Please Improve You Question. What i understand form it here is the base Idea.

  1. Upload File On Server

    So please review this answer for idea of uploading an file on server

  2. Show ProgressView

    First You need to add progressView in UI Thread and then create another thread for communicating with server that thread will responsible for uploading file and with base idea callback as response from server with in UI Thread and remove progressView.

like review this code

dispatch_queue_t anotherThreadQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
//add progress view here...
dispatch_async(anotherThreadQueue, ^{
        //then upload file here....
dispatch_async(dispatch_get_main_queue(), ^{
            // UI Thread update View ( remove progressView)
      });
 });

or for showing the progress for uploading file you can use connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: as you using NSURLConnection

Community
  • 1
  • 1
Buntylm
  • 7,345
  • 1
  • 31
  • 51