问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/27239101/pfquerytableviewcontroller-in-swift-using-cloud-code-function