gpt4 book ai didi

ios - Eureka 表单(Swift)中的 MultipleSelectorRow 如何将 FormValues 转换为字符串数组?

转载 作者:行者123 更新时间:2023-11-28 07:32:00 34 4
gpt4 key购买 nike

谁能帮我从 Eureka 表单的 MultipleSelectorRow 中检索值?

我有一个像这样的多选行,其中列出了楼层。

  <<< MultipleSelectorRow <String> {
$0.title = " *Floor"
$0.tag = "floor"
$0.options = floorArray
$0.validationOptions = .validatesOnChange
$0.add(rule: RuleRequired())
}.onPresent { from, to in
to.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: from, action: #selector(SRElementsForInspectionVC.multipleSelectorDone(_:)))
}.cellUpdate({(cell , row) in
if !row.isValid{
// CELL BORDER HAS TO BE RED
cell.textLabel?.textColor = .red

} else {
// do something
}
})

然后当我尝试检索我调用的提交按钮上的值时,

let formvalues = self.form.values()
if let floor = formvalues["floor"]{
if floor != nil{
print(floor)

for f in floor as! [String: Any] {
let fl = f as! String
print(fl)
// Print the floor
}

}
}

但我无法获得正确的转换。请帮忙。

Optional(Set(["4", "1", "3", "2"])) Could not cast value of type 'Swift.Set' (0x7fe07537f348) to 'Swift.Dictionary' (0x10999ed38). 2019-01-30 12:48:36.283692+0530 SIDERISE[22242:772718] Could not cast value of type 'Swift.Set' (0x7fe07537f348) to 'Swift.Dictionary' (0x10999ed38).

最佳答案

是的,你可以这样解决

if let _floors = formvalues["floor"] as? Set<String> {
for _floor in _floors{
print(_floor)
}
}

我和一个 friend 花了 90 分钟/2 小时来解决这个问题

关于ios - Eureka 表单(Swift)中的 MultipleSelectorRow 如何将 FormValues 转换为字符串数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54435206/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com