zkid
@zkid
студентик

Как тестировать геолокацию?

Сделал функцию определения местоположения.
Однако программа вылетает при выключенной геолокации.
Какие эксепшены прописываете обычно?
Что то пробовал мифами написать
CLLocationManager.locationServicesEnabled() == true)


Но всегда true возвращает.
Что посоветуете?
Если что, вот код кнопки:

@IBAction func CurrentLocation(sender: AnyObject) {
        
        if (CLLocationManager.locationServicesEnabled() == true) {
            let userLocation = locationmanager.location
        
            let center = CLLocationCoordinate2D(latitude: userLocation!.coordinate.latitude, longitude: userLocation!.coordinate.longitude)
        
            var currentAnnotation = MKPointAnnotation()
            currentAnnotation.coordinate = center
            currentAnnotation.title = "You're here!"
        
            MapApple.addAnnotation(currentAnnotation)
            
            print("location is enabled")
        }
        
        else {
            print("location is diable")
            let AlertButton = UIAlertController(title: "Geo", message: "You need to switch it on", preferredStyle: .Alert)
            
        }
  • Вопрос задан
  • 430 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы