Skip to content

Instantly share code, notes, and snippets.

@lukeredpath
Last active August 29, 2015 14:14
Show Gist options
  • Save lukeredpath/ac1febab203050d21fea to your computer and use it in GitHub Desktop.
Save lukeredpath/ac1febab203050d21fea to your computer and use it in GitHub Desktop.
Display location on map when authorised
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