作者:仰望天空说再见 | 来源:互联网 | 2023-01-12 03:48
Iwanttofetchallofthelocationrecordsfromauserthatiscurrentlyloggedin.我想从当前登录的用户那里获取所
I want to fetch all of the location records from a user that is currently logged in.
我想从当前登录的用户那里获取所有的位置记录。
This creates the location record on CloudKit:
这在CloudKit上创建了位置记录:
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations.last!
let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
addCrumbPoint(center)
let locatiOnRecord= CKRecord(recordType: "location")
locationRecord["location"] = location
let publicData = CKContainer.defaultContainer().publicCloudDatabase
publicData.saveRecord(locationRecord) { record, error in
}
}
But how would I go about pulling out the location records for only the currently logged in user?
但是,我如何只提取当前登录用户的位置记录呢?
I want to use this to create a breadcrumb of previous journeys on a map but just getting it to print a list would be a great start!
我想用这个来在地图上创建一个以前旅行的面包屑,但是仅仅是让它打印一个列表将是一个很好的开始!
Here is my code so far:
这是我目前的代码:
func getLocationAsync(complete: (instance: CKRecordID?, error: NSError?) -> ()) {
let cOntainer= CKRecordID(recordName: "Location")
publicDB.fetchRecordWithID(location) { fetchedLocation, error in
if error != nil {
print(error!.localizedDescription)
complete(instance: nil, error: error)
} else {
print("fetched Location \(recordID?.recordName)")
complete(instance: recordID, error: nil)
}
}
}
1 个解决方案