PFQueryTableViewController in Swift using Cloud Code function

可紊 提交于 2019-12-25 06:57:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!