使用eureka基于对象设置文本

时间:2016-11-12 13:12:49

标签: swift eureka-forms

我正在尝试根据领域对象中的名称设置值,但是它会在单元格中显示Ladder {作为文本而不是name。这是我的代码

    <<< MultipleSelectorRow<Ladder>("Rank") {
           $0.hidden = Condition.predicate(NSPredicate(format: "$Game == nil"))
           $0.title = $0.tag


           }.cellUpdate { cell, row in

               let formvalues = self.form.values()
               let game = formvalues["Game"] as! Game
               let ranks = Array(game.ranks)
               row.options = ranks
               row.displayValueFor = { (rowValue: Set<Ladder>?) in
                   return rowValue?.map({ $0.name }).sorted().joined(separator: ", ")
               }


               cell.textLabel?.font = UIFont(name: "Avenir-Book", size: 16)

               cell.preservesSuperviewLayoutMargins = false
               cell.separatorInset = UIEdgeInsets.zero
               cell.layoutMargins = UIEdgeInsets.zero

       }

排名输出

[Ladder {
    id = 58268b08f5f51a16b8d53472;
    name = Bronze;
}, Ladder {
    id = 58268b08f5f51a16b8d53473;
    name = Silver;
}, Ladder {
    id = 58268b08f5f51a16b8d53474;
    name = Gold;
}, Ladder {
    id = 58268b08f5f51a16b8d53475;
    name = Platinium;
}, Ladder {
    id = 58268b08f5f51a16b8d53476;
    name = Diamond;
}, Ladder {
    id = 58268b08f5f51a16b8d53477;
    name = Master;
}, Ladder {
    id = 58268b08f5f51a16b8d53478;
    name = Challenger;
}]

领域模型

class Ladder: Object {

    dynamic var id = ""
    dynamic var name = ""

    override static func primaryKey() -> String? {
        return "id"
    }

}

0 个答案:

没有答案