Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Cleaned up NSLocalizedString usage
Browse files Browse the repository at this point in the history
The format string would be localized, not the string resulting from expanding its placeholders. Also unindented a wildly indented block of code.
  • Loading branch information
1ec5 committed Mar 6, 2016
1 parent 2d2ba3a commit 0875a06
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions platform/ios/src/MGLAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 0875a06

Please sign in to comment.