如何从json数据将字典结构分配给Bindable类型

时间:2019-02-10 03:36:54

标签: ios json swift

我通过Bindable使用MVVM,我可以使用以下代码分配数组,但是我应该如何分配字典数据

    func getSmallCaseList(id:String) {
        showLoadingHud.value = true
        appServerClient.getSmallCaseDetails(scid: id, completion: { [weak self] result in
            self?.showLoadingHud.value = false
            switch result {
            case .success(let data):
                guard data.success == true else {
               //error -type of expression is ambiguous without more context
                    self?.caseDetailsCardCell.value = [.empty]
                    return
                }
                self?.caseDetailsCardCell.value = data.compactMap { .normal(cellViewModel: $0 as CaseCardCellVM)}

            case .failure(let error):
                self?.caseDetailsCardCell.value = [.error(message: error?.getErrorMessage() ?? "Loading failed, check network connection")]
            }
        })
    }

了解更多代码详细信息link to gist

任何帮助都会非常有用
谢谢

0 个答案:

没有答案