我有一个变量ranks
,输出如下,但这是Any
类型。但是,我想将其转换为Array<Ladder>
到目前为止,我已尝试编写as! [Ladder]
,但无效。
Optional(Optional(Set([Ladder {
id = 58268b08f5f51a16b8d53474;
name = Gold;
}, Ladder {
id = 58268b08f5f51a16b8d53478;
name = Challenger;
}, Ladder {
id = 58268b08f5f51a16b8d53476;
name = Diamond;
}])))
尤里卡功能
<<< 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
}