@@ -46,21 +46,19 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ
46
46
_fileQueue.maxConcurrentOperationCount = 4 ;
47
47
}
48
48
49
- __weak __block NSBlockOperation *weakOp ;
50
- __block NSBlockOperation *op = [ NSBlockOperation blockOperationWithBlock: ^{
51
- // [macOS
52
- NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
49
+ NSBlockOperation *op = [ NSBlockOperation new ] ;
50
+ __weak NSBlockOperation *weakOp = op;
51
+ [op addExecutionBlock: ^{
52
+ NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
53
53
if (strongOp == nil || [strongOp isCancelled ]) {
54
54
return ;
55
55
}
56
- // macOS]
57
-
58
56
// Get content length
59
57
NSError *error = nil ;
60
58
NSFileManager *fileManager = [NSFileManager new ];
61
59
NSDictionary <NSString *, id > *fileAttributes = [fileManager attributesOfItemAtPath: request.URL.path error: &error];
62
60
if (!fileAttributes) {
63
- [delegate URLRequest: strongOp didCompleteWithError: error]; // [macOS]
61
+ [delegate URLRequest: strongOp didCompleteWithError: error];
64
62
return ;
65
63
}
66
64
@@ -77,17 +75,16 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ
77
75
expectedContentLength: [fileAttributes[NSFileSize ] ?: @-1 integerValue ]
78
76
textEncodingName: nil ];
79
77
80
- [delegate URLRequest: strongOp didReceiveResponse: response]; // [macOS]
78
+ [delegate URLRequest: strongOp didReceiveResponse: response];
81
79
82
80
// Load data
83
81
NSData *data = [NSData dataWithContentsOfURL: request.URL options: NSDataReadingMappedIfSafe error: &error];
84
82
if (data) {
85
- [delegate URLRequest: strongOp didReceiveData: data]; // [macOS]
83
+ [delegate URLRequest: strongOp didReceiveData: data];
86
84
}
87
- [delegate URLRequest: strongOp didCompleteWithError: error]; // [macOS]
85
+ [delegate URLRequest: strongOp didCompleteWithError: error];
88
86
}];
89
87
90
- weakOp = op;
91
88
[_fileQueue addOperation: op];
92
89
return op;
93
90
}
0 commit comments