-1
ユーザーの場所をクラウドキットで更新したいのですが、私のコードは毎回新しいレコードを保存するだけです。既存のレコードは、どのように変更したり、新しいレコードに置き換えることができますか?swiftでckrecordを修正しようとしています
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.01, longitudeDelta: 0.01))
self.mapView.setRegion(region, animated: true)
self.locationManager.stopUpdatingLocation()
locationRecord.setObject(location, forKey: "location")
let publicData = CKContainer.defaultContainer().publicCloudDatabase
publicData.saveRecord(locationRecord) { record, error in
}
if error == nil
{
print("Location saved")
self.loc1 = location!
}
}
保存を実行し、元のレコードIDなど
への参照をキャッシュすることにより、これを行うだろう'? – matt
let locationRecord = CKRecord(recordType: "location")@matt – Steve
あなたの問題があります。 _existing_レコードを変更したいのであれば、なぜ新しい_レコードを作成していますか? – matt