0
私がParseからクエリしたオブジェクトをUITableViewで使用できる配列にプッシュしようとするのに少し問題があります。Swift 3の配列にオブジェクトを追加する
ここに私のコードです。
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
}
locationCell