I am creating an app that loads data into a UITableView from Parse. I used some code that seems to work for loading the retrieved data into the cells in the table, but it is buggy and I did some research and found the PFQueryTableViewController. This seems like the solution to my problem, but all the documentation is in Objective-C (which I do not have any experience coding in), and there are no tutorials from what I could find on how to use this class in Swift. There are a few snippets that talk about how to initialize it, but nothing that really goes through how to set it up in Swift. I tried to go through the Obj-C documentation and set it up myself in Swift but I can't seem to get it right and would really appreciate some help. Does anyone have a suggested resource or has anyone set one up and could step through how to do this in Swift?
EDIT: I have found some resources and tried to get it set up, the table view loads but nothing is loaded into the cells and I am not sure. I am going to leave the code below. The commented out section wasn't relevant to my code but left it for reference. Any further help as to why the table isn't loading would be helpful!
class MyCookbookVC : PFQueryTableViewController {
override init!(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
textKey = "Name"
pullToRefreshEnabled = true
paginationEnabled = true
objectsPerPage = 25
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
tableView.reloadData()
}
override func queryForTable() -> PFQuery! {
let query = PFUser.query()
query.whereKey("CreatedBy", equalTo: PFUser.currentUser())
query.orderByAscending("Name")
//if network cannot find any data, go to cached (local disk data)
if (self.objects.count == 0){
query.cachePolicy = kPFCachePolicyCacheThenNetwork
}
return query
}
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as PFTableViewCell
cell.textLabel?.text = object["Name"] as? String
/*if let profileImage = object["profileImage"] as? PFFile {
cell.imageView.file = profileImage
}
else {
cell.imageView.image = kProfileDefaultProfileImage
}
cell.imageView.layer.cornerRadius = cell.imageView.frame.size.width / 2;
cell.imageView.clipsToBounds = true
cell.imageView.layer.borderWidth = 3.0
cell.imageView.layer.borderColor = UIColor.whiteColor().CGColor */
/* cell.textLabel?.font = UIFont(name: kStandardFontName, size: kStandardFontSize)
cell.textLabel?.textColor = UIColor.whiteColor()
cell.backgroundColor = kbackgroundColor */
return cell
}
}