我试图设置MultipleSelectorRow的显示值。但是,当我尝试在下面进行编译时,我会在return t.name
处出现错误,并说Value of type Set<Ladder> has no member name
。 let ranks = Array(game.ranks)
的类型为Array<Ladder>
。为了从Ladder对象中显示名称,我做错了什么?
<<< 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 = {
if let t = $0 {
return t.name
}
return nil
}
cell.textLabel?.font = UIFont(name: "Avenir-Book", size: 16)
cell.preservesSuperviewLayoutMargins = false
cell.separatorInset = UIEdgeInsets.zero
cell.layoutMargins = UIEdgeInsets.zero
}
阶梯课
class Ladder: Object, Mappable{
dynamic var id = ""
dynamic var name = ""
override static func primaryKey() -> String? {
return "id"
}
required convenience init?(map: Map) {
self.init()
}
func mapping(map: Map) {
id <- map["_id"]
name <- map["name"]
}
override var description: String {
return "\(self.name)"
}
}