Skip to content

Commit 910cfa9

Browse files
committed
Merge pull request #170 from ParsePlatform/nlutsenko.location.deprecated
Remove usage of deprecated APIs in PFLocationManager.
2 parents 65936b2 + 7c7da49 commit 910cfa9

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

Parse/Internal/PFLocationManager.m

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,35 +115,20 @@ - (void)addBlockForCurrentLocation:(PFLocationManagerLocationUpdateBlock)handler
115115
#pragma mark - CLLocationManagerDelegate
116116
///--------------------------------------
117117

118-
// TODO: (nlutsenko) Remove usage of this method, when we drop support for OSX 10.8
119-
#pragma clang diagnostic push
120-
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
121-
- (void)locationManager:(CLLocationManager *)manager
122-
didUpdateToLocation:(CLLocation *)newLocation
123-
fromLocation:(CLLocation *)oldLocation {
118+
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
119+
CLLocation *location = [locations lastObject];
120+
124121
[manager stopUpdatingLocation];
125122

126123
NSMutableSet *callbacks = [NSMutableSet setWithCapacity:1];
127124
@synchronized (self.blockSet) {
128125
[callbacks setSet:self.blockSet];
129126
[self.blockSet removeAllObjects];
130127
}
131-
for (void(^block)(CLLocation *, NSError *) in callbacks) {
132-
block(newLocation, nil);
128+
for (PFLocationManagerLocationUpdateBlock block in callbacks) {
129+
block(location, nil);
133130
}
134131
}
135-
#pragma clang diagnostic pop
136-
137-
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
138-
CLLocation *location = [locations lastObject];
139-
CLLocation *oldLocation = [locations count] > 1 ? [locations objectAtIndex:[locations count] - 2] : nil;
140-
141-
// TODO: (nlutsenko) Remove usage of this method, when we drop support for OSX 10.8 (didUpdateLocations is 10.9+)
142-
#pragma clang diagnostic push
143-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
144-
[self locationManager:manager didUpdateToLocation:location fromLocation:oldLocation];
145-
#pragma clang diagnostic pop
146-
}
147132

148133
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
149134
[manager stopUpdatingLocation];

Tests/Other/LocationManager/CLLocationManager+TestAdditions.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,7 @@ - (void)overriddenStartUpdatingLocation {
7979
} else if (returnLocation) {
8080
CLLocation *fakeLocation = [[CLLocation alloc] initWithLatitude:CL_DEFAULT_LATITUDE
8181
longitude:CL_DEFAULT_LONGITUDE];
82-
#if PARSE_IOS_ONLY
83-
[self.delegate locationManager:self didUpdateLocations:[NSArray arrayWithObject:fakeLocation]];
84-
#else
85-
CLLocation *emptyLocation = [[CLLocation alloc] initWithLatitude:CL_DEFAULT_LATITUDE
86-
longitude:CL_DEFAULT_LONGITUDE];
87-
[self.delegate locationManager:self didUpdateToLocation:fakeLocation fromLocation:emptyLocation];
88-
#endif
82+
[self.delegate locationManager:self didUpdateLocations:@[ fakeLocation ]];
8983
}
9084
}
9185

0 commit comments

Comments
 (0)