1
votes

I want to import some data from my parse via PFQueryTableView and Cell. I configured a tableview on storyboard and assign both tableview and it's cell with PFQueryTableViewController and PFQueryTableViewCell. So on my tableview controller i'm using this code below but it gives me error on super.init(className: myClassName) line with a message of "Must call a designated initializer of the superclass 'PFQueryTableViewController'"

import UIKit
import Parse
import ParseUI

class parseTableView: PFQueryTableViewController {

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)!
    }

        init(className myClassName: String!) {
        super.init(className: myClassName)

        self.parseClassName = myColoumnName
        self.textKey = "myObjectKey"
        self.pullToRefreshEnabled = true
        self.paginationEnabled = false
    }
}
2

2 Answers

0
votes

You need to override queryForTable:

  // Define the query that will provide the data for the table view
  override func queryForTable() -> PFQuery {
    var query = PFQuery(className: "myClassName")
    return query
  }

In addition, on self.parseClassName = myColoumnName you should give a class name not a columnName.

Also, you need to override init:

  // Initialise the PFQueryTable tableview
  override init(style: UITableViewStyle, className: String!) {
    super.init(style: style, className: className)
  }

You can find more details here.

0
votes

You have to replace the

super.init(className: myClassName)

to

super.init(style: .Plain, className: myClassName)

I inspected the PFQueryTableViewController class implementation and I think that is because of some kind of imperfection related to with bridging Swift to Objective-C. It is related to with the designated initializer in Swift. Because the upper init method is not set to Designated Initializer and bottom one is.