如何动态创建PushRow并通过alamofire函数传递值。这是我的alamofire函数,我想使用alamofire响应创建pushRow
nw.getJsonData(api: Api.assetCategory) { (response, error) in
}
func createPushRow(_ title: String, _ placeholder: String, _ options: [String]) {
form +++ Section("Choose " + title)
<<< PushRow<String>() { row in
row.title = title.lowercased()
row.selectorTitle = "Pick " + title.lowercased()
row.options = options
}
}
答案 0 :(得分:2)
您可以像这样更改PushRow
的选项:
(form.rowBy(tag: "<tagOfRow>") as? PushRow<String>)?.options = ["", "", ""]
或者您可以将行初始化器中的optionsProvider
设置为lazy
,并在每次选择PushRow时获取选项。
form +++ Section("Choose " + title)
<<< PushRow<String>() { row in
row.optionsProvider = .lazy({ (formViewController, completion) in
// Call Alamofire to get options
// options = ...
completion(options)
})
// .... other set up
}