Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor WMFLocationManager to Swift #3

Open
wants to merge 19 commits into
base: develop
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Move reverse geocoding out of LocationManager

  • Loading branch information
jantimar authored and VojtaStavik committed Feb 28, 2020
commit 8bc1544824e2566c7e2fb503897a5abc98c3727f
@@ -46,9 +46,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)isAuthorizationDenied;
+ (BOOL)isAuthorizationRestricted;

- (void)reverseGeocodeLocation:(CLLocation *)location completion:(void (^)(CLPlacemark *placemark))completion
failure:(void (^)(NSError *error))failure;

@end

@protocol WMFLocationManagerDelegate <NSObject>
@@ -293,20 +293,6 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
}
}

#pragma mark - Geocoding

- (void)reverseGeocodeLocation:(CLLocation *)location completion:(void (^)(CLPlacemark *placemark))completion
failure:(void (^)(NSError *error))failure {
[[[CLGeocoder alloc] init] reverseGeocodeLocation:location
completionHandler:^(NSArray<CLPlacemark *> *_Nullable placemarks, NSError *_Nullable error) {
if (failure && error) {
failure(error);
} else if (completion) {
completion(placemarks.firstObject);
}
}];
}

@end

NS_ASSUME_NONNULL_END
@@ -264,7 +264,7 @@ - (void)getGroupForLocation:(CLLocation *)location inManagedObjectContext:(NSMan
return;
}

[self.currentLocationManager reverseGeocodeLocation:location
[self reverseGeocodeLocation:location
completion:^(CLPlacemark *_Nonnull placemark) {
completion(nil, location, placemark);
self.isProcessingLocation = NO;
@@ -339,4 +339,16 @@ - (void)removeSectionsForMidnightUTCDate:(NSDate *)midnightUTCDate withKeyNotEqu
}];
}

- (void)reverseGeocodeLocation:(CLLocation *)location completion:(void (^)(CLPlacemark *placemark))completion
failure:(void (^)(NSError *error))failure {
[[[CLGeocoder alloc] init] reverseGeocodeLocation:location
completionHandler:^(NSArray<CLPlacemark *> *_Nullable placemarks, NSError *_Nullable error) {
if (failure && error) {
failure(error);
} else if (completion) {
completion(placemarks.firstObject);
}
}];
}

@end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.