set googleMapApi timeout

phiz_2.41.5.7
Stewen 2023-08-23 17:33:29 +08:00
parent c030e31a5a
commit 99d074d023
1 changed files with 9 additions and 4 deletions

View File

@ -199,14 +199,18 @@
urlComponents.queryItems = queryItems; urlComponents.queryItems = queryItems;
request.URL = urlComponents.URL; request.URL = urlComponents.URL;
} }
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.timeoutIntervalForRequest = 5.0;
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { if (error) {
NSLog(@"Error: %@", error); NSLog(@"Error: %@", error);
completion(nil); completion(nil);
return; return;
} }
if (data) { if (data) {
NSError *jsonError; NSError *jsonError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
@ -220,8 +224,9 @@
completion(nil); completion(nil);
} }
}]; }];
[task resume]; [task resume];
} }
+ (NSArray *)convertPlaceDictToArray:(NSDictionary*)dict{ + (NSArray *)convertPlaceDictToArray:(NSDictionary*)dict{