iOS开发表单快速构建(仅供记录)

构建表单有很多种方式,目前我更倾向于model中绑定

let kAddNewNoticeInfoDataArr = [["sectionTtitle" : "公告信息", "sectionImage" : "notice_admin_add_info", "infoArr" : [["title" : "公告标题", "placeholder" : "请输入公告标题", "isSelected" : false],
                                                                                     ["title" : "案号", "placeholder" : "请输入案号", "isSelected" : false],
                                                                                     ["title" : "公告内容", "placeholder" : "请输入公告内容", "isSelected" : true]]],
                            ["sectionTtitle" : "资料上传", "sectionImage" : "notice_admin_add_introduce", "infoArr" : [["title" : "竞拍须知", "placeholder" : "请输入竞拍须知", "isSelected" : true]]],
                            ["sectionTtitle" : "关联标的", "sectionImage" : "notice_admin_add_lot", "infoArr" : [["title" : "关联标的", "placeholder" : "请选择标的", "isSelected" : true]]]]

class AddNewNoticeModel: BaseModel {

    var sectionTtitle: String?
    var sectionImage: String?
    var infoArr: Array?
}

class AddNewNoticeInfoModel: BaseModel {

  var title: String?
  var placeholder: String?
  var isSelected: Bool?
  var content: String = ""
}

在viewmodel中转成model

func getData() -> Array {
    
    let dataArr = [AddNewNoticeModel].deserialize(from: kAddNewNoticeInfoDataArr)
    return dataArr! as! Array
}

然后在进行数据绑定

你可能感兴趣的:(iOS开发表单快速构建(仅供记录))