Ich habe Probleme beim Abrufen der Standorte aus Cloudkit. Der Standort wird hochgeladen, aber wenn ich versuche, sie auszudrucken und zu laden, werden sie nicht heruntergeladen. Ich bekomme keine Fehler.Probleme beim Abrufen von Daten aus CloudKit
Diese Funktion lädt die Lage zu Wolkenjungen:
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
let location = locations.last
let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.015, longitudeDelta: 0.015))
self.mapView.setRegion(region, animated: true)
self.locationManager.stopUpdatingLocation()//
let locationRecord = CKRecord(recordType: "location")
locationRecord.setObject(location, forKey: "location")
let publicData = CKContainer.defaultContainer().publicCloudDatabase
publicData.saveRecord(locationRecord) { record, error in
}
if error == nil
{
print("Location saved")
}
event1 = locations
}
diese Funktion wird die Standorte von Wolkenjungen holt:
func loadLocation()
{
let locations = [CKRecord]()
let publicData1 = CKContainer.defaultContainer().publicCloudDatabase
let query1 = CKQuery(recordType: "location", predicate: NSPredicate(format: "TRUEPREDICATE", argumentArray:nil))
publicData1.performQuery(query1, inZoneWithID: nil) { (results: [CKRecord]?, error: NSError?) -> Void in
if let locations = results
{
self.locations = locations
print(locations)
}
}
}
Können Sie näher erläutern, was das Problem genau ist? Wird 'CLLocationCoordinate2D' von' CKRecords' erzeugt? Zeigt es Pins auf einer Karte an? –
Momentan kann ich CLLocationCoordinate2D nicht erstellen. Ich denke auch nicht, dass die Orte überhaupt abgeholt werden. @grimfrog – Steve
Die Klammern sind falsch im Speichercode. Aber du musst wissen, dass das, was du hast, nicht richtig kompiliert wird? – Rob