Having a bit of trouble trying to push objects that I query from Parse into an array that I can use in a UITableView.
Here's my code.
var locations = [AnyObject]()
override func viewDidLoad() {
super.viewDidLoad()
// Query the Locations class.
let query = PFQuery(className:"Location")
query.findObjectsInBackground {
(objects: [PFObject]?, error: Error?) -> Void in
if error == nil {
if let objects = objects {
for object in objects {
self.locations.append(object)
}
self.venueTable.reloadData()
}
} else {
// Log details of the failure
print("Error: (error!) (error!.userInfo)")
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return locations.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let locationCell = tableView.dequeueReusableCell(withIdentifier: "locationCell", for: indexPath)
let location = locations[indexPath.row]
locationCell.textLabel?.text = location
return locationCell
}
After the for loop, locations is full of the parse data, but not sure how to access it when pushing it to the locationCell