Я работаю по интеграции GoogleMaps IOS SDK в свой проект, и я получаю эту ошибку:GoogleMaps IOS SDK GMSMapView Класс высвобождены
'NSInternalInconsistencyException' 'An instance 0x7fea5e93e210 of class GMSMapView was deallocated while key value observers were still registered with it. Current observation info:
Вот мой код вид контроллера:
import UIKit
import GoogleMaps
class ViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate {
var locationManager = CLLocationManager()
var didFindMyLocation = false
let mapView = GMSMapView()
override func viewDidLoad() {
super.viewDidLoad()
let mapView = GMSMapView()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
let camera: GMSCameraPosition = GMSCameraPosition.cameraWithLatitude(37.61729,longitude: -122.38229, zoom: 18)
mapView.camera = camera
mapView.delegate = self
mapView.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.New, context: nil)
}
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if !didFindMyLocation {
let myLocation: CLLocation = change![NSKeyValueChangeNewKey] as! CLLocation
mapView.camera = GMSCameraPosition.cameraWithTarget(myLocation.coordinate, zoom: 18.0)
mapView.settings.myLocationButton = true
didFindMyLocation = true
}
}
}