I'm trying to make a simple by feet navigator, using a arrow image, rotating to indicate the direction to follow with a constant refresh.
Using magneticHeading
i found error unexpectedly found nil while unwrapping an Optional value
, maybe i forgot something.
How i can use correctly magneticHeading?
var northLatitude :CLLocationDegrees
var latitude :CLLocationDegrees = 46.0
var longitude :CLLocationDegrees = 7.0
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
longitude = manager.location.coordinate.longitude
latitude = manager.location.coordinate.latitude
var buildingLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
var regionOfInterest:MKCoordinateRegion = MKCoordinateRegionMake(buildingLocation, span)
self.mapView.setRegion(regionOfInterest, animated: true)
self.mapView.addAnnotation(buildingAnnotation)
northLatitude = manager.heading.magneticHeading //ERROR
}