0

i am using NSURLConnection and it's delegates to upload file to the server. I am using below method to get how much data gas been send till now.

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

I am getting output as below:

    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 32768
    bytesWritten : 2408
    bytesWritten : 3828
    bytesWritten : 3828
    bytesWritten : 2840
    bytesWritten : 4260
    bytesWritten : 5680
    bytesWritten : 2840
    bytesWritten : 7100

My question is: Why am I getting inconsistent data? For first few records, I am getting maximum byteWritten value and for the next it's very moderate.

Can anyone help to understand this inconsistency?

iAsh
  • 447
  • 6
  • 19
  • Not sure, But "bytesWritten : 32768" default value of bytesWritten, that means byte value is not start to written yet. as soon as it get actual value and start to written value could be changed. – Dipen Chudasama Jan 12 '15 at 09:01
  • But, how could I initialise it? I am showing this value on speedometer. because of this speedometer shows weird behaviour... :( – iAsh Jan 12 '15 at 09:03

1 Answers1

0

I came to the conclusion that connection starts sending maximum bytes through the network. As and when server starts responding to the incoming data this byte size gets finalise according to network strength.

Thank you.

iAsh
  • 447
  • 6
  • 19