Skip to content

Commit

Permalink
replace deprecated sendSynchronousRequest:returningResponse:error:
Browse files Browse the repository at this point in the history
…with `dataTaskWithURL:completionHandler:`
  • Loading branch information
Pavlos Vinieratos authored and Pavlos Vinieratos committed Jun 5, 2018
1 parent 3b4947a commit ccce82f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions React/Base/RCTBundleURLProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ - (void)resetToDefaults
- (BOOL)isPackagerRunning:(NSString *)host
{
NSURL *url = [serverRootWithHost(host) URLByAppendingPathComponent:@"status"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLResponse *response;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];
__block NSData *data;

dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[[[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *d, NSURLResponse *response, NSError *error) {
data = d;
dispatch_semaphore_signal(semaphore);
}] resume];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
return [status isEqualToString:@"packager-status:running"];
}
Expand Down

0 comments on commit ccce82f

Please sign in to comment.