Last active
August 29, 2015 14:14
-
-
Save lukeredpath/ac1febab203050d21fea to your computer and use it in GitHub Desktop.
Display location on map when authorised
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([CLLocationManager locationServicesEnabled]) { | |
self.locationManager = [[CLLocationManager alloc] init]; | |
self.locationManager.delegate = self; | |
RACSignal *locationAuthorizationStatus = [[RACSignal | |
concat:@[ | |
[RACSignal return:@([CLLocationManager authorizationStatus])], | |
[[self rac_signalForSelector:@selector(locationManager:didChangeAuthorizationStatus:) fromProtocol:@protocol(CLLocationManagerDelegate)] map:^id(RACTuple *arguments) { | |
return arguments.second; | |
}] | |
]] | |
doNext:^(NSNumber *value) { | |
if ([value intValue] == kCLAuthorizationStatusNotDetermined) { | |
[self.locationManager requestWhenInUseAuthorization]; | |
} | |
} | |
]; | |
RAC(self.mapView, showsUserLocation, @NO) = [locationAuthorizationStatus map:^id(NSNumber *value) { | |
return @([value intValue] == kCLAuthorizationStatusAuthorizedWhenInUse); | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment