Sfoglia il codice sorgente

Fix potential IOS progress report error #210

Ben Hsieh 7 anni fa
parent
commit
2044427250
1 ha cambiato i file con 25 aggiunte e 20 eliminazioni
  1. 25
    20
      src/ios/RNFetchBlobNetwork.m

+ 25
- 20
src/ios/RNFetchBlobNetwork.m Vedi File

32
 NSMutableDictionary * progressTable;
32
 NSMutableDictionary * progressTable;
33
 NSMutableDictionary * uploadProgressTable;
33
 NSMutableDictionary * uploadProgressTable;
34
 
34
 
35
+__attribute__((constructor))
36
+static void initialize_tables() {
37
+    if(expirationTable == nil)
38
+    {
39
+        expirationTable = [[NSMapTable alloc] init];
40
+    }
41
+    if(taskTable == nil)
42
+    {
43
+        taskTable = [[NSMapTable alloc] init];
44
+    }
45
+    if(progressTable == nil)
46
+    {
47
+        progressTable = [[NSMutableDictionary alloc] init];
48
+    }
49
+    if(uploadProgressTable == nil)
50
+    {
51
+        uploadProgressTable = [[NSMutableDictionary alloc] init];
52
+    }
53
+    if(cookiesTable == nil)
54
+    {
55
+        cookiesTable = [[NSMapTable alloc] init];
56
+    }
57
+}
58
+
59
+
35
 typedef NS_ENUM(NSUInteger, ResponseFormat) {
60
 typedef NS_ENUM(NSUInteger, ResponseFormat) {
36
     UTF8,
61
     UTF8,
37
     BASE64,
62
     BASE64,
78
         taskQueue = [[NSOperationQueue alloc] init];
103
         taskQueue = [[NSOperationQueue alloc] init];
79
         taskQueue.maxConcurrentOperationCount = 10;
104
         taskQueue.maxConcurrentOperationCount = 10;
80
     }
105
     }
81
-    if(expirationTable == nil)
82
-    {
83
-        expirationTable = [[NSMapTable alloc] init];
84
-    }
85
-    if(taskTable == nil)
86
-    {
87
-        taskTable = [[NSMapTable alloc] init];
88
-    }
89
-    if(progressTable == nil)
90
-    {
91
-        progressTable = [[NSMutableDictionary alloc] init];
92
-    }
93
-    if(uploadProgressTable == nil)
94
-    {
95
-        uploadProgressTable = [[NSMutableDictionary alloc] init];
96
-    }
97
-    if(cookiesTable == nil)
98
-    {
99
-        cookiesTable = [[NSMapTable alloc] init];
100
-    }
101
     return self;
106
     return self;
102
 }
107
 }
103
 
108