From 0875a066cbcfdd65784c3bf838a1039dbe865a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sat, 5 Mar 2016 21:49:57 -0800 Subject: [PATCH] [ios] Cleaned up NSLocalizedString usage The format string would be localized, not the string resulting from expanding its placeholders. Also unindented a wildly indented block of code. --- platform/ios/src/MGLAPIClient.m | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/platform/ios/src/MGLAPIClient.m b/platform/ios/src/MGLAPIClient.m index 601edd6a4ed..441c7c16f96 100644 --- a/platform/ios/src/MGLAPIClient.m +++ b/platform/ios/src/MGLAPIClient.m @@ -44,22 +44,22 @@ - (instancetype)init { - (void)postEvents:(nonnull NS_ARRAY_OF(MGLMapboxEventAttributes *) *)events completionHandler:(nullable void (^)(NSError * _Nullable error))completionHandler { __block NSURLSessionDataTask *dataTask = [self.session dataTaskWithRequest:[self requestForEvents:events] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; - NSError *statusError = nil; - if (httpResponse.statusCode >= 400) { - NSString *description = [NSString stringWithFormat:@"The session data task failed. Original request was: %@", dataTask.originalRequest]; - NSString *reason = [NSString stringWithFormat:@"The status code was %@", @(httpResponse.statusCode)]; - NSDictionary *userInfo = @{NSLocalizedDescriptionKey: NSLocalizedString(description, nil), - NSLocalizedFailureReasonErrorKey: NSLocalizedString(reason, nil)}; - statusError = [NSError errorWithDomain:MGLErrorDomain code:1 userInfo:userInfo]; - } - if (completionHandler) { - error = error ? error : statusError; - completionHandler(error); - } - [self.dataTasks removeObject:dataTask]; - dataTask = nil; - }]; + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + NSError *statusError = nil; + if (httpResponse.statusCode >= 400) { + NSString *description = [NSString stringWithFormat:NSLocalizedString(@"The session data task failed. Original request was: %@", nil), dataTask.originalRequest]; + NSString *reason = [NSString stringWithFormat:NSLocalizedString(@"The status code was %ld", nil), (long)httpResponse.statusCode]; + NSDictionary *userInfo = @{NSLocalizedDescriptionKey: description, + NSLocalizedFailureReasonErrorKey: reason}; + statusError = [NSError errorWithDomain:MGLErrorDomain code:1 userInfo:userInfo]; + } + if (completionHandler) { + error = error ? error : statusError; + completionHandler(error); + } + [self.dataTasks removeObject:dataTask]; + dataTask = nil; + }]; [dataTask resume]; [self.dataTasks addObject:dataTask]; }