Ich habe eine App, die Orte in einer Tabellenansicht zeigt, die über eine Schaltfläche auf einer Karte hinzugefügt werden kann. Ich habe Probleme beim Speichern dieser zu analysieren (ja, ich weiß, es ist im Ruhestand, aber ich habe einen neuen Server eingerichtet, der genau das gleiche funktioniert so denke, es ist parse) auch ich habe dieses Thema betrachtet: https://stackoverflow.com/questions/30435362/how-can-i-send-coordinates-to-parse-and-save-it-as-parse-pfgeopoin t und auch wenn es aussieht ziemlich einfach es hat mich noch so hier verwirrt ist mein Code in meinem TableviewWie kann ich Standorte (Pins) auf einem Parse-Server speichern?
var places = [Dictionary<String,String>()]
var activePlace = -1
und hier ist der Code, Anzeigen ein Stift (in der Steuerung Kartenansicht)
@IBAction func addSpot(sender: UIBarButtonItem) {
var newCoordinate2 = self.map.userLocation.location!.coordinate;
var location = CLLocation(latitude: newCoordinate2.latitude, longitude: newCoordinate2.longitude)
//title = "new address"
//try change order start
let annotation = MKPointAnnotation()
self.map.addAnnotation(annotation)
annotation.coordinate = newCoordinate2
annotation.title = title
annotation.coordinate = self.map.userLocation.location!.coordinate;
CLGeocoder().reverseGeocodeLocation(location) { (placemarks, error) -> Void in
var title = ""
if (error == nil) {
if let p = placemarks?[0] {
var subThouroughfare:String = ""
var thouroughfare:String = ""
if p.subThoroughfare != nil {
subThouroughfare = p.subThoroughfare!
}
if p.thoroughfare != nil {
thouroughfare = p.thoroughfare!
}
title = "\(subThouroughfare) \(thouroughfare)"
}
}
if title == "" {
title = "Added \(NSDate())"
}
places.append(["name":title,"lat":"\(newCoordinate2.latitude)","lon":"\(newCoordinate2.longitude)"])
let annotation = MKPointAnnotation()
annotation.coordinate = newCoordinate2
annotation.title = title
self.map.addAnnotation(annotation)
}
self.map.addAnnotation(annotation);
func mapView(mapView: MKMapView!,
viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView!{
if(annotation is MKUserLocation){
return nil;
}
// let pinView: Void = mapView.addAnnotation(annotation);
let pinAnnotationView = MKPinAnnotationView(annotation: annotation,reuseIdentifier:"MyIdentifier");
return pinAnnotationView;
}
}
danken Ihnen für die Unterstützung als Ich bin neu zu verwenden parse/externe Server
EDIT: Ich habe dies versucht:
PFObject["geoPoint"] = PFGeoPoint(location: location)
location[location] = activePlace
location.saveInBackgroundWithBlock { (succes, error) -> Void in
print("place has been saved")
}
bekomme ich Fehler auf den drei Leitungen 1) Instanz Mitglied ‚Index‘ kann nicht auf Typ 2 ‚PFObject‘ verwendet werden) Typ ‚CLLocation‘ hat keine Index Mitglieder 3) Wert vom Typ CLLocation hat kein Mitglied ‚saveInBackgroundWithBlock‘
RE EDIT: ich dies versucht haben, und eine Warnung sagen auch ‚Code nach der Rückkehr wird nie ausgeführt werden‘ es läuft auf der App aber nicht gespeichert
let geoPoint = PFObject(className: "location")
geoPoint["location"] = activePlace
geoPoint.saveInBackgroundWithBlock { (succes, error) -> Void in
print("place has been saved")
}
Sie haben nicht erklärt, was Ihr Code falsch macht – Wain
Es macht nichts falsch, aber es wird nicht zum Parsen hochgeladen. Ich weiß nur nicht, wie ich die Orte hinzufügen muss, die ich analysieren muss @Wain –
hast du ein PFObject definiert, das deinen Standort/jeden Ort enthält? – Wain