Я учусь использовать новый язык Swift (только Swift, без Objective-C). Для этого я хочу сделать простой вид с картой (MKMapView
). Я хочу найти и обновить местоположение пользователя (как в приложении Apple Map).
Я попробовал это, но ничего не произошло:
import MapKit
import CoreLocation
class MapView : UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var map: MKMapView!
var locationManager: CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
if (CLLocationManager.locationServicesEnabled())
{
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
}
}
}
Не могли бы вы мне помочь?