【问题标题】:Unable to fetch data in collection from kinvey to a table view controller无法将集合中的数据从 kinvey 获取到表视图控制器
【发布时间】:2016-03-27 14:48:25
【问题描述】:

您好,我在 kinvey 有一个包含两列 Team1 和 Team2 的集合。现在我需要获取这些数据并将其分配给 Table 视图控制器中的 Label1 和 label2。我已经实现了一个模型类来获取数据。这是我的模型类代码。

class FixtureData:NSObject{

var Team1:NSString!
var Team2: NSString!
var entityId: NSString?

init(Team1:String, Team2:String) {
    self.Team1 = Team1
    self.Team2 = Team2
    print(Team1)

}
override var description:String {
    return "Team1: \(Team1!)"
}
override init(){
    super.init()
}  

下面是代码。我已从 Kinvey 获取它以将 Kinvey 中的列映射到我的代码。

        override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! 

{ 返回 [ "entityId" : KCSEntityKeyId, //必填的_id字段 “团队 1”:“团队 1”, “团队 2”:“团队 2”,}

这里的问题是,如果我在 Team1 和 Team2 设置断点并检查我没有从 kinvey 获得任何数据。

我的表格视图控制器有这个代码

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("FixtureCell", forIndexPath: indexPath)
    var team1Lbl : UILabel = cell.viewWithTag(5) as! UILabel
    let team2Lbl : UILabel = cell.viewWithTag(6) as! UILabel
    let fc = FixtureData()
    fc.hostToKinveyPropertyMapping()
    team1Lbl.text = Team1[indexPath.row]
    team2Lbl.text = Team2[indexPath.row]}

所以请有人告诉我我应该在代码中修改什么来获取数据。

【问题讨论】:

    标签: xcode swift uitableview kinvey


    【解决方案1】:

    我没有在您的代码中看到 KCSAppdataStore 实现。 KCSAppdataStore 是数据的基类,允许您从后端发送和加载数据。

    详细查看以下链接以更好地了解实现:

    http://devcenter.kinvey.com/ios/guides/datastore#KCSAppdataStore

    谢谢, 普拉纳夫

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 2019-04-30
      • 2018-03-23
      • 1970-01-01
      • 1970-01-01
      • 2017-10-25
      • 2013-04-09
      相关资源
      最近更新 更多