Unable to fetch data in collection from kinvey to a table view controller

时间:2016-03-27 14:48:25

标签: xcode swift uitableview kinvey

Hi i have a collection in kinvey with two columns Team1 & Team2. Now i need to fetch this data and assign it to Label1 & label2 in the Table view controller. I have implemented a model class to fetch the data. Here is my Model Class Code.

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

Below is the code. I have taken it from Kinvey to map the columns in Kinvey to my code.

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

{ return [ "entityId" : KCSEntityKeyId, //the required _id field "Team1" : "Team1", "Team2" : "Team2",}

The problem here is if i put a break point at Team1 & Team2 and check i am not getting any data from kinvey.

My table view controller has this code

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

So here please some one let me know what should i modify in the code, to fetch the data.

1 个答案:

答案 0 :(得分:4)

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

详细检查以下链接,以便更好地理解实施:

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

谢谢, Pranav