swift - 使用未声明的类型 'BackendlessCollection'

标签 swift backendless

大家好,我是 Backendless 的新手。请帮忙。我在 ios 中使用 Use of undeclared type 'BackendlessCollection' 时遇到错误。 swift

我在主视图 Controller 中编写了函数 retrieveBlurbs()。我又创建了一个像这样的对象 medicineList 类

class medicineList : NSObject
{

    var objectId : String?
    var name : String?

    var desc : String?
    var created : NSDate?
    var updated : NSDate?

}


func retrieveBlurbs()
{
    var backendless = Backendless.sharedInstance()
    let query = BackendlessDataQuery()
    // Use backendless.persistenceService to obtain a ref to a data store for the class
    backendless.persistenceService.ofTable(medicineList.ofClass()).find(query, response: { ( medicineList : BackendlessCollection!) -> () in
        let currentPage = medicineList.getCurrentPage()
        print("Loaded \(currentPage.count) medicineList objects")
        print("Total restaurants in the Backendless starage - \(medicineList.totalObjects)")

        for medicineList in currentPage as! [medicineList]
        {
            print("Medicine name = \(medicineList.name)")
        }




    } , error: { ( fault : Fault!) -> () in
            print("Server reported an error: \(fault)")
        })
}

最佳答案

enter image description here我不确定,这会有所帮助

我看过 API,所以如果您使用异步方法签名,带有查询变量的方法“find”有两个非可选 block 用于响应和错误。

我会尝试像这样更改该方法:

func retrieveBlurbs()
{
    var backendless = Backendless.sharedInstance()
    let query = BackendlessDataQuery()
    // Use backendless.persistenceService to obtain a ref to a data store for the class
    backendless.persistenceService.ofTable(medicineList.ofClass()).find(query) { medicineList in
        let currentPage = medicineList.getCurrentPage()
        print("Loaded \(currentPage.count) medicineList objects")
        print("Total restaurants in the Backendless starage - \(medicineList.totalObjects)")

        for medicineList in currentPage as! [medicineList]
        {
            print("Medicine name = \(medicineList.name)")
        }

    } , { fault in
            print("Server reported an error: \(fault)")
        }
}

如果这没有帮助,那么也许您必须从​​一开始就进行 sdk 设置,在第一次设置期间可能会丢失某些模块或文件

关于swift - 使用未声明的类型 'BackendlessCollection',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45749900/

相关文章:

ios - Health 处理多步骤源的方式与 HealthKit 不同——swift

ios - 无后端查询的空 TableView 结果,如何填充到表中

java - Backendless CodeRunner 未向无后端服务器注册

ios - Backendless swift 如何从 MBAAS 存储加载对象

java - Google Play - onReceivedSslError

ios - 如何在 Swift 中将类型作为参数传递

objective-c - swift 类 : Fatal error: Use of unimplemented initializer 'init()' for class

swift - 如何根据通用类型在 Swift 中拥有默认和专用功能?

ios - 缓慢的 Swift 字符串性能