Skip to content

Commit ccce82f

Browse files
Pavlos VinieratosPavlos Vinieratos
authored andcommitted
replace deprecated sendSynchronousRequest:returningResponse:error: with dataTaskWithURL:completionHandler:
1 parent 3b4947a commit ccce82f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

React/Base/RCTBundleURLProvider.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,16 @@ - (void)resetToDefaults
6969
- (BOOL)isPackagerRunning:(NSString *)host
7070
{
7171
NSURL *url = [serverRootWithHost(host) URLByAppendingPathComponent:@"status"];
72-
NSURLRequest *request = [NSURLRequest requestWithURL:url];
73-
NSURLResponse *response;
74-
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];
72+
__block NSData *data;
73+
74+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
75+
[[[NSURLSession sharedSession] dataTaskWithURL:url
76+
completionHandler:^(NSData *d, NSURLResponse *response, NSError *error) {
77+
data = d;
78+
dispatch_semaphore_signal(semaphore);
79+
}] resume];
80+
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
81+
7582
NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
7683
return [status isEqualToString:@"packager-status:running"];
7784
}

0 commit comments

Comments
 (0)