【发布时间】:2020-02-17 07:35:15
【问题描述】:
我想问一下如何将选定的所有项目保存在 tableViewCell 中,如下图所示。所以以后我可以用 alamofire 发布它,我以前没有发布数据的经验。这就是我所做的。
这是我的按钮,因此我可以稍后使用 alamofire 发布,目前我想对其进行测试。
@objc func handleSubmit() {
var data: [String] = []
for (index, value) in attendance.enumerated() {
print("index attendance: \(index), value attendance: \(value.status)")
let cell = tableView.cellForRow(at: IndexPath(item: index, section: 0)) as? GStudentAbsenceCell
UserServices.shared.postUserAttendances(status: cell?.status ?? "")
data.append(cell?.status ?? String(index))
}
print(data)
}
// In My UITableViewCell
var status: String?
statusLbl.didSelect { (selectedText , index ,id) in
if selectedText == "Sakit" || selectedText == "Izin" || selectedText == "Alpha" {
self.status = selectedText
self.statusLbl.backgroundColor = #colorLiteral(red: 0.8666666667, green: 0.4078431373, blue: 0.2705882353, alpha: 0.2)
self.statusLbl.textColor = #colorLiteral(red: 0.8666666667, green: 0.4078431373, blue: 0.2705882353, alpha: 1)
}
}
【问题讨论】:
-
创建单元格模型并根据选择进行存储和加载
-
好吧你的意思,但是当我存储单元格时。如果我创建单元格模型,我必须在我的发布请求中传递什么参数?抱歉@Vinodh 这是我第一次这样做
标签: ios swift uitableview alamofire