ich aktualisierte Xcode 6 zu Xcode 7 Beta mit Swift 2. Ich bekomme diesen Fehler und ich kann nicht herausfinden, wie man es beheben kann, bitte helfen Sie mir. Vielen Dank. Dies ist mein Code:Swift 2 CLLocationManager Fehler beim Aktualisieren
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [AnyObject]) {
let location = locations.last as! CLLocation
let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
self.map.setRegion(region, animated: true)
}
und ich bekomme diese Fehlermeldung:
Objective-C method 'locationManager:didUpdateLocations:' provided by method 'locationManager(_:didUpdateLocations:)' conflicts with optional requirement method 'locationManager(_:didUpdateLocations:)' in protocol 'CLLocationManagerDelegate'
'AnyObject' ist ein Überbegriff von' CLLocation'. Beides sollte funktionieren. – akashivskyy
Ich weiß, aber als ich es von [AnyObject] zu [CLLocation] änderte, ging der Fehler weg. –
schon versucht, dass es funktioniert, aber dann gab es mir einen Fehler in dieser Zeile: 'Lassen Sie location = locations.last as! CLLocation' sagte, dass locations.last kein CLLocation sein kann – markutus