ios - Eureka 表单(Swift)中的 MultipleSelectorRow 如何将 FormValues 转换为字符串数组?
问题描述
有人可以帮我从 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
}
}
}
但我无法获得正确的演员表。请帮忙。
可选(Set([“4”,“1”,“3”,“2”]))无法将类型“Swift.Set”(0x7fe07537f348)的值转换为“Swift.Dictionary”(0x10999ed38)。2019-01-30 12:48:36.283692+0530 SIDERISE[22242:772718] 无法将“Swift.Set”(0x7fe07537f348)类型的值转换为“Swift.Dictionary”(0x10999ed38)。
解决方案
是的,你像这样解决这个问题
if let _floors = formvalues["floor"] as? Set<String> {
for _floor in _floors{
print(_floor)
}
}
我和一个朋友花了 90 分钟/2 小时才解决这个问题
推荐阅读
- c# - OSX DOTNET 附加到进程
- android - 有没有办法在Android中将连拍照片分组
- java - 如何在 Java 中静音 Snackbar 的 Android 应用程序通知?
- python - 如何查找目录中的文件是否被其他用户使用
- flutter - 将变量从有状态小部件传递到状态
- express - 在 Nuxt 和 Express 中上传图片
- python - django 中的表单不会检索数据并保存它
- stm32 - STM32:USART 替代功能不起作用
- c# - ODATA (8.0.0-RC) URI 中指定的查询无效。属性“Id”不能在 $filter 查询选项中使用
- java - 使用 JPA 查询可以为空的 @OneToOne 关系(反向)