Last active
September 15, 2015 12:21
-
-
Save Cellane/f1c7243b24c42e41345b to your computer and use it in GitHub Desktop.
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
- (IBAction)obtainCoordinates:(UIButton *)sender { | |
sender.enabled = NO; | |
[CLLocationManager promise].then(^(CLLocation *location) { | |
self.fromTextField.text = [NSString stringWithFormat:@"GPS: %f,%f", location.coordinate.latitude, location.coordinate.longitude]; | |
}).catch(^(NSError *error) { | |
[self presentGPSError:error]; | |
}).finally(^{ | |
sender.enabled = YES; | |
}); | |
} | |
- (void)presentGPSError:(NSError *)error { | |
if (error.code == 1) { | |
[self presentViewController:[AINContext current].settingsAlertController animated:YES completion:nil]; | |
} else { | |
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Chyba GPS" message:@"Nepodařilo se zjistit současnou polohu, zkuste to prosím později." preferredStyle:UIAlertControllerStyleAlert]; | |
[alertController addAction:[UIAlertAction actionWithTitle:@"Rozumím" style:UIAlertActionStyleCancel handler:nil]]; | |
[self presentViewController:alertController animated:YES completion:nil]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment