Explorar el Código

#1 correct ios progress report value

Ben Hsieh hace 8 años
padre
commit
d0455c987c
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4
    2
      src/ios/RNFetchBlob/RNFetchBlob.m

+ 4
- 2
src/ios/RNFetchBlob/RNFetchBlob.m Ver fichero

@@ -54,6 +54,8 @@
54 54
     self.respData = [[NSMutableData alloc] initWithLength:0];
55 55
     self.callback = callback;
56 56
     self.bridge = bridgeRef;
57
+    self.expectedBytes = 0;
58
+    self.receivedBytes = 0;
57 59
     // Call long-running code on background thread
58 60
     NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:NO];
59 61
     [conn scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
@@ -74,7 +76,7 @@
74 76
 }
75 77
 
76 78
 - (void) connection:(NSURLConnection *)connection didReceiveData:(nonnull NSData *)data {
77
-    receivedBytes = data.length;
79
+    receivedBytes += data.length;
78 80
     [respData appendData:data];
79 81
     
80 82
     [self.bridge.eventDispatcher
@@ -90,7 +92,7 @@
90 92
 - (void) connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
91 93
     
92 94
     expectedBytes = totalBytesExpectedToWrite;
93
-    receivedBytes = totalBytesWritten;
95
+    receivedBytes += totalBytesWritten;
94 96
     [self.bridge.eventDispatcher
95 97
         sendAppEventWithName:@"RNFetchBlobProgress"
96 98
             body:@{