Created
August 5, 2015 14:24
-
-
Save Bashta/89975d21a13b3f217e63 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
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