dan*_*ads 4 ios swift eureka-forms
有没有办法从 json/api 响应构建 eureka 表单。到目前为止,我已经能够转换为返回到对象的 json。但在创建 for 循环来生成表单时遇到问题。
form
+++ Section("API Returns")
for values in JSONObject{
<<< TextRow() {
$0.tag = values.key
$0.title = values.name
$0.value = values.value
}
}
Run Code Online (Sandbox Code Playgroud)
您需要指示 TextRow 将插入到循环内的哪个部分。
let section = Section("API Returns")
form +++ section
for values in JSONObject{
section <<< TextRow() {
$0.tag = values.key
$0.title = values.name
$0.value = values.value
}
}
Run Code Online (Sandbox Code Playgroud)
假设您的“API Returns”部分是表单的最后部分,您也可以使用此选项。
for values in JSONObject {
guard let section = self.form.last else {
return
}
section <<< TextRow() {
$0.tag = values.key
$0.title = values.name
$0.value = values.value
}
}
Run Code Online (Sandbox Code Playgroud)