1
Не знаете, почему это не работает? любая помощь будет принята с благодарностью. Thnks.Почему я получаю Неустранимая ошибка: неожиданно найден нуль при распаковке необязательного значения ... вот мой код:
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
var locationManager:CLLocationManager!
@IBOutlet weak var mapView: MKMapView!
@IBAction func nowButton(sender: AnyObject) {
}
@IBOutlet weak var mapLabel: UILabel!
@IBAction func bookButton(sender: AnyObject) {
}
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager.requestAlwaysAuthorization()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self
locationManager.startUpdatingLocation()
mapView.showsUserLocation = true
mapView.delegate = self
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
let regionToZoom = MKCoordinateRegionMake(manager.location.coordinate, MKCoordinateSpanMake(0.05, 0.05))
mapView.setRegion(regionToZoom, animated: true)
}
}
Какая строка дает вам ошибку? –
В дополнение к вышесказанному, все ваши '' IBOutlet 'ы связаны? – Rich