File tree Expand file tree Collapse file tree
packages/react-native/Libraries/Network Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,13 +49,8 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ
4949 _queue.maxConcurrentOperationCount = 2 ;
5050 }
5151
52- __weak NSBlockOperation *weakOp;
53- NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock: ^{
54- NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
55- if (strongOp == nil || [strongOp isCancelled ]) {
56- return ;
57- }
58-
52+ __weak __block NSBlockOperation *weakOp;
53+ __block NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock: ^{
5954 // Get mime type
6055 NSRange firstSemicolon = [request.URL .resourceSpecifier rangeOfString: @" ;" ];
6156 NSString *mimeType =
@@ -67,15 +62,15 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ
6762 expectedContentLength: -1
6863 textEncodingName: nil ];
6964
70- [delegate URLRequest: strongOp didReceiveResponse: response];
65+ [delegate URLRequest: weakOp didReceiveResponse: response];
7166
7267 // Load data
7368 NSError *error;
7469 NSData *data = [NSData dataWithContentsOfURL: request.URL options: NSDataReadingMappedIfSafe error: &error];
7570 if (data) {
76- [delegate URLRequest: strongOp didReceiveData: data];
71+ [delegate URLRequest: weakOp didReceiveData: data];
7772 }
78- [delegate URLRequest: strongOp didCompleteWithError: error];
73+ [delegate URLRequest: weakOp didCompleteWithError: error];
7974 }];
8075
8176 weakOp = op;
Original file line number Diff line number Diff line change @@ -53,19 +53,14 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ
5353 _fileQueue.maxConcurrentOperationCount = 4 ;
5454 }
5555
56- __weak NSBlockOperation *weakOp;
57- NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock: ^{
58- NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
59- if (strongOp == nil || [strongOp isCancelled ]) {
60- return ;
61- }
62-
56+ __weak __block NSBlockOperation *weakOp;
57+ __block NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock: ^{
6358 // Get content length
6459 NSError *error = nil ;
6560 NSFileManager *fileManager = [NSFileManager new ];
6661 NSDictionary <NSString *, id > *fileAttributes = [fileManager attributesOfItemAtPath: request.URL .path error: &error];
6762 if (!fileAttributes) {
68- [delegate URLRequest: strongOp didCompleteWithError: error];
63+ [delegate URLRequest: weakOp didCompleteWithError: error];
6964 return ;
7065 }
7166
@@ -82,14 +77,14 @@ - (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequ
8277 expectedContentLength: [fileAttributes[NSFileSize ] ?: @-1 integerValue ]
8378 textEncodingName: nil ];
8479
85- [delegate URLRequest: strongOp didReceiveResponse: response];
80+ [delegate URLRequest: weakOp didReceiveResponse: response];
8681
8782 // Load data
8883 NSData *data = [NSData dataWithContentsOfURL: request.URL options: NSDataReadingMappedIfSafe error: &error];
8984 if (data) {
90- [delegate URLRequest: strongOp didReceiveData: data];
85+ [delegate URLRequest: weakOp didReceiveData: data];
9186 }
92- [delegate URLRequest: strongOp didCompleteWithError: error];
87+ [delegate URLRequest: weakOp didCompleteWithError: error];
9388 }];
9489
9590 weakOp = op;
You can’t perform that action at this time.
0 commit comments