mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-27 14:19:59 +08:00
Fix xcode warnings (#23565)
Summary: As part of #22609, this fixes yet more warnings. - Adding more __unused to params. - Refactors `isPackagerRunning` to use NSURLSession. - Turns off suspicious comma warnings [iOS] [Fixed] - Xcode Warnings Pull Request resolved: https://github.com/facebook/react-native/pull/23565 Differential Revision: D14161151 Pulled By: cpojer fbshipit-source-id: 339874711eca718fc6151e84737ccc975225d736
This commit is contained in:
committed by
Facebook Github Bot
parent
9820c88877
commit
468ae234a6
@@ -69,9 +69,23 @@ static NSURL *serverRootWithHost(NSString *host)
|
||||
- (BOOL)isPackagerRunning:(NSString *)host
|
||||
{
|
||||
NSURL *url = [serverRootWithHost(host) URLByAppendingPathComponent:@"status"];
|
||||
|
||||
NSURLSession *session = [NSURLSession sharedSession];
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
||||
NSURLResponse *response;
|
||||
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];
|
||||
__block NSURLResponse *response;
|
||||
__block NSData *data;
|
||||
|
||||
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
||||
[[session dataTaskWithRequest:request
|
||||
completionHandler:^(NSData *d,
|
||||
NSURLResponse *res,
|
||||
__unused NSError *err) {
|
||||
data = d;
|
||||
response = res;
|
||||
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"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user