How can i send coordinates to Parse fetched by CLLocation and save it there as PFGeoPoint's latitude and longitude?
I am able to get the coordinates from CLLocation and I want to send it to Parse. In Parse I have a column named "coordinates" of type PFGeoPoint which has two fields.Now I want to save the coordinates which I have got from CLLocation to Parse Column coordinates. can anyone please help me with this? I am new to iOS and Parse.
Two steps:
Convert CLLocation to PFGeoPoint
//SWIFT
let point = PFGeoPoint(location: currentLoc)
//Obj-c
[PFGeoPoint *point = PFGeoPoint geoPointWithLocation:(PF_NULLABLE CLLocation *)location];
Now save it.
//SWIFT
object["coordinates"] = point
object.saveInBackgroundWithBlock {
(success: Bool, error: NSError?) -> Void in
if (success) {
// The object has been saved.
} else {
// There was a problem, check error.description
}
}
//Obj-c
object["coordinates"] = point;
[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
// The object has been saved.
} else {
// There was a problem, check error.description
}
}];