title: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee84eaf60) for my CLLocationManager()
body: <p>I have no idea why this started or how to solve it.  The error: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee84eaf60) occurs on my line:</p>
  <pre><code>let locationManager = CLLocationManager()
  </code></pre>
  <p>I declared it in my class above viewDidLoad().  I've run this simulator a ton of times without this problem, and it randomly popped up now.  I checked to make sure it wasn't the most recent code I added by running it again without said code, and the error persists.  Just in case you think of this, it's not that my default location is set to none, I've had that error before and fixed it.  Here are all the parts of my code where my locationManager is used:</p>
  <pre><code>let locationManager = CLLocationManager()
  </code></pre>
  <p>then:</p>
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      
      locationManager.delegate = self
      locationManager.requestWhenInUseAuthorization()
      locationManager.startUpdatingLocation()
      
      mapView.delegate = self
      mapView.showsUserLocation = true
      
      tapToAddJumpSpotLabel.isHidden = true
  }
  </code></pre>
  <p>then:</p>
  <pre><code>@IBAction func allowLocationButtonPressed(_ sender: UIBarButtonItem) {
  
      switch CLLocationManager.authorizationStatus() {
  
      // Case when authorization not determined.
      case .notDetermined:
          locationManager.requestWhenInUseAuthorization()
  
      // Case when authorization granted.
      case .authorizedAlways, .authorizedWhenInUse:
          let alertController = UIAlertController(title: &quot;Location Access Granted&quot;, message: &quot;We already have access to your location.  If you want to change this, go to your settings app, and change our location access.&quot;, preferredStyle: .alert)
  
          let okayAction = UIAlertAction(title: &quot;Okay&quot;, style: .cancel, handler: nil)
  
          alertController.addAction(okayAction)
  
          self.present(alertController, animated: true, completion: nil)
  
      // Case when authorization denied or restricted.
      case .restricted, .denied:
          let alertController = UIAlertController(title: &quot;Location Access Disabled&quot;, message: &quot;We need access to your location in order to provide you with cliff jumping spots.&quot;, preferredStyle: .alert)
  
          let cancelAction = UIAlertAction(title: &quot;Cancel&quot;, style: .cancel, handler: nil)
  
          let openAction = UIAlertAction(title: &quot;Open Settings&quot;, style: .default) { (action) in
              if let url = URL(string: UIApplication.openSettingsURLString) {
                  UIApplication.shared.open(url, options: [:], completionHandler: nil)
              }
          }
          alertController.addAction(cancelAction)
          alertController.addAction(openAction)
  
          self.present(alertController, animated: true, completion: nil)
  
      // Default (Apple has possible future cases to be added to CLAuthorizationStatus).
      @unknown default:
          return
      }
  }
  </code></pre>
  <p>finally:</p>
  <pre><code>//MARK: - CLLocationManagerDelegate Methods
  
  extension ViewController: CLLocationManagerDelegate {
  
  func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
      if let error = error as? CLError, error.code == .denied {
          locationManager.stopUpdatingLocation()
          print(error)
          return
      }
      
  }
  
  func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
      let lastLocation = locations.last!
      mapView.centerCoordinate.latitude = lastLocation.coordinate.latitude
      mapView.centerCoordinate.longitude = lastLocation.coordinate.longitude
  }
  </code></pre>
  <p>}</p>
  <p>I have no idea what is causing this so any help is appreciated :)</p>