4

I have added a UITableViewController to storyboard and created/assigned a new class which inherits from PFQueryTableViewController to the storyboard controller. I then wrote the following init functions but I am unable to get the Table view controller working correctly.

What needs to be implemented in order to instantiate the PFQueryTableViewController? The code in the Parse doc is not working correctly in swift.

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

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

    self.parseClassName = "Timeline"
    self.textKey = "Name"
    self.pullToRefreshEnabled = true
    self.paginationEnabled = false
}
Tony Abboud
  • 2,420
  • 1
  • 14
  • 12

2 Answers2

4

You need to initialize the ViewController. As a test, initialize it in your appdelegate like this:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    Parse.setApplicationId("YOUR_APP_ID", clientKey:"YOUR_CLIENT_KEY")
    var controller:PFQueryTableViewController = PFQueryTableViewController(className: "YOUR_PARSE_CLASS_NAME")
    self.window?.rootViewController = controller
    return true
}

Here is my PFQUeryTableViewController

class TestTableViewController: PFQueryTableViewController {

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

override init(className aClassName: String!) {
    super.init(className: aClassName)

    self.parseClassName = aClassName
    self.textKey = "YOUR_PARSE_COLOMN_YOU_WANT_TO_SHOW"
    self.pullToRefreshEnabled = true
    self.paginationEnabled = false
}
}

Hope this helps, let me know if you have any questions. Note, we need to pass in a class name in the initializer for this class. We pass that class name in the appdelegate here, but when we add this view to another controller, we would pass in the class name there instead. This was more to get you up and running

Rufflez
  • 214
  • 2
  • 9
  • I am having some trouble. My PFQueryTableViewController is embedded in a Navigation Controller so I cannot set self.window.rootViewController = controller because I have some properties of my NavVC in there (therefore they will be nil). Therefore, what would be the correct way of instantiating the PFQueryTableViewController? – idelara Jun 26 '15 at 02:24
1

This is sorta lame advice.

But just make the class in ObjC and include it in your Bridging Header

Krtko
  • 1,055
  • 18
  • 24