Skip to content

Instantly share code, notes, and snippets.

@Bashta
Created August 5, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bashta/89975d21a13b3f217e63 to your computer and use it in GitHub Desktop.
Save Bashta/89975d21a13b3f217e63 to your computer and use it in GitHub Desktop.
private extension NewMessageViewController {
func checkLocationPermisions() {
let status = CLLocationManager.authorizationStatus()
switch status {
case .NotDetermined:
dataMgr.locationManager.requestWhenInUseAuthorization()
break
case .AuthorizedWhenInUse:
fallthrough
case .AuthorizedAlways:
dataMgr.locationManager.startUpdatingLocation()
case .Restricted:
fallthrough
case .Denied:
askForPermisions()
}
}
func askForPermisions() {
var alert = UIAlertView(title: "Important", message: "Some fields might be missing, since the app requires to access your current location in order to provide more data. Please consider allowing WYA to access your location in the settings menu", delegate: self, cancelButtonTitle: "Ok")
alert.show()
}
}
extension NewMessageViewController: CLLocationManagerDelegate {
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
switch status {
case .AuthorizedWhenInUse:
fallthrough
case .AuthorizedAlways:
dataMgr.locationManager.startUpdatingLocation()
case .Restricted:
fallthrough
case .Denied:
askForPermisions()
default:
break
}
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
contentTableView.reloadData()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment