0

I'm trying to convert a simple UITableViewController to PFQueryTableViewController in Swift. So far I know I have to initialise my class like that: (source)

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
}
}

I have two problems:

  • somehow I cannot import PFQueryTableViewController
  • I would like to use a cloud function for feeding my table instead of a Query object.

Any idea?

Community
  • 1
  • 1
Claus
  • 5,662
  • 10
  • 77
  • 118

1 Answers1

2

In bridging header for Swift you need to import "ParseUI.h" as below. Then you need to initialize the class name in 'init:coder'

#import '<ParseUI/ParseUI.h>'

Init of PFQueryTableViewController class object

override init!(style: UITableViewStyle, className: String!) {
    super.init(style: style, className: className)
}


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

    self.parseClassName = "MyClass"
    self.pullToRefreshEnabled = true
    self.paginationEnabled = true
    self.objectsPerPage = 50
}

```

Regarding the second question, if you are about to use the Parse Cloud Function so there's no need to use the PFQueryTableViewController class. Just using the normal UITableViewController and run your cloud function upon controller initialization

Azri Jamil
  • 2,394
  • 2
  • 29
  • 37
  • 1
    thanks for you answer. About the second point, I would be interested in the paging functionality of the PFQueryTableViewController so I was wondering if there is anyway to pass this class a PFCloud function instead of a PFQuery – Claus Dec 07 '14 at 18:21
  • Thanks @Wajatimur - That extra import caught me out. – Ian Bradbury Jan 29 '15 at 16:14