Here's my locationManager function, can someone please tell me why I'm getting the error: 'fatal error: unexpectedly found nil while unwrapping Optional value'?
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation: CLLocation = locations[0] as CLLocation
CLGeocoder().reverseGeocodeLocation(userLocation) { (placemarks, error) -> Void in
if (error != nil) {
print(error)
} else {
if placemarks!.count > 0 {
if let pm = placemarks![0] as CLPlacemark! {
print(pm)
self.locationButtonLabel.text = "\(pm.subLocality!),\(pm.locality!)"
}
}
}
}
}