我正在尝试使用我在官方 Backendless 文档上在线找到的函数从在线数据存储中检索数据!但是当我尝试使用像 Lista(我自己的类)对象这样的角色时,我收到错误:无法将类型“__NSDictionaryM”(0x10c1ccfc0)的值转换为“InLIsta_.Lista”(0x108439790)。我在这个网站上搜索,但答案并不特定于 Backendless 案例,所以我希望任何人都可以帮助我
这是我的代码(显然我已经声明了所有的 var 并让代码有必要运行):
class Lista : NSObject {
var nome: String?
var pr: String?
var pagamento = 0
var entrato: Bool = false
var commenti: String?
var objectId: String?
var created: NSDate?
var updated: NSDate?
}
func findQ() {
Types.tryblock({ () -> Void in
let startTime = NSDate()
let found = self.backendless.persistenceService.of(Lista.ofClass()).find(self.query)
let currentPage = found.getCurrentPage()
print("Loaded \(currentPage.count) name objects")
print("Total name in the Backendless storage - \(found.totalObjects)")
for person in currentPage {
let persona = person as! Lista // here i get error
print("Restaurant <\(Lista.ofClass())> name = \(persona.nome)")
self.nomi.append(persona.nome!)
}
print("Total time (ms) - \(1000*NSDate().timeIntervalSinceDate(startTime))")
},
catchblock: { (exception) -> Void in
print("Server reported an error: \(exception as! Fault)")
}
)
}