Swift 中的 PFQueryTableViewController 使用 Cloud Code 函数 [英] PFQueryTableViewController in Swift using Cloud Code function

查看:49
本文介绍了Swift 中的 PFQueryTableViewController 使用 Cloud Code 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Swift 中将一个简单的 UITableViewController 转换为 PFQueryTableViewController.到目前为止,我知道我必须像这样初始化我的类:(source)

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

我有两个问题:

  • 不知何故我无法导入 PFQueryTableViewController
  • 我想使用云函数而不是 Query 对象来填充我的表.

有什么想法吗?

推荐答案

在 Swift 的桥接头中,您需要导入如下所示的ParseUI.h".然后需要在'init:coder'中初始化类名

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

PFQueryTableViewController 类对象的初始化

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
}

```

关于第二个问题,如果您即将使用 Parse Cloud Function,则无需使用 PFQueryTableViewController 类.只需使用普通的 UITableViewController 并在控制器初始化时运行您的云功能

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

这篇关于Swift 中的 PFQueryTableViewController 使用 Cloud Code 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆