首页 > 解决方案 > 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)。

标签: iosswifteureka-forms

解决方案


是的,你像这样解决这个问题

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

我和一个朋友花了 90 分钟/2 小时才解决这个问题


推荐阅读