In my ViewController
I have a label which displays the name of a club selected in the previous ViewController
. I now need to create a query from my parse.com class to retrieve all information on the object that matches the club name displayed as a label. I know how to successfully query parse but I'm finding it hard to find a way to match the query with the label String seeing as the label String can be different depending on what club was selected in the previous view.
Code:
import UIKit
import Parse
class MenuController: UIViewController {
@IBOutlet weak var clubLabel: UILabel!
var clubName = String()
override func viewDidLoad() {
super.viewDidLoad()
clubLabel.text = clubName
}
}
Previous View already queried parse to populate map with club annotations like so:
let annotationQuery = PFQuery(className: "Clubs")
annotationQuery.findObjectsInBackgroundWithBlock{
(clubs, error) -> Void in
if error == nil {
// The find succeeded.
print("Successful query for annotations")
// Do something with the found objects
let myClubs = clubs! as [PFObject]
for club in myClubs {
//data for annotation
let annotation = MKPointAnnotation()
let place = club["location"] as? PFGeoPoint
let clubName = club["clubName"] as? String
let stadiumName = club["stadium"] as? String
annotation.title = clubName
annotation.subtitle = stadiumName
annotation.coordinate = CLLocationCoordinate2DMake(place!.latitude,place!.longitude)
//add annotations
self.mapView.addAnnotation(annotation)