问题描述
我一直在不断使这次崩溃崩溃,而且我已经失去线索了几周了。任何见识将不胜感激,以了解我在这里错过了什么。该代码段显示如下,并带有错误日志。
崩溃的代码
func validateFormFields (){
var formType: FORMS_TYPE? = .LOG
dispatchQueue.main.async {
//Where this crashes i guess according to the Error Log
if FormsValidationManager.shared.validate(tableView: self.tableView,presentVC: self,formType: self.formType!) {
dispatchQueue.main.async {
SwiftSpinner.show("Saving prospect form")
}
//Save Prospect Form
self.formsviewmodel.saveProspect(tableView: self.tableView,self.contactList) {
self.formDataCompletionDelegate?.relaodTableData(formType: .PROSPECT)
self.dismiss(animated: true,completion: nil) //Exit Prospect form
}
}
}
}
FormsValidationManager.shared.validate类中的代码如下
func validate(tableView: UITableView,presentVC: UITableViewController,formType: FORMS_TYPE) -> Bool {
if formType == FORMS_TYPE.LOG {//Log form validation
let logFormCell = tableView.cellForRow(at: IndexPath(row: 0,section: 0))
if logFormCell != nil {
textFieldValues.append(anotherDict: getTextFieldValues(enumType: LOG_FORM_TF_TAGS.self,cell: logFormCell))//add values to dict
if let validationMessage = getValidationMessage(textFieldValues: textFieldValues,formType: formType,cell: [logFormCell!]) {
Utils.shared.addReloaDalert(message: validationMessage,presentVC: presentVC,title: Constants.ALERT_TITLE)
return false//form is invalid
}
}
}
}
private func getTextFieldValues<T: RawRepresentable & CaseIterable>(enumType: T.Type,cell: UITableViewCell?) -> [String: String?] where T.RawValue == Int {
var textFieldValues: [String: String?] = [String: String?]()
for (_,element) in enumType.allCases.enumerated() {
if let textField = cell?.viewWithTag(element.rawValue) as? UITextField {
let caseLabelName = getEnumCaseLabelName(value: String(describing: enumType.init(rawValue: element.rawValue)))
if textField.text!.isEmpty {
textFieldValues.updateValue(nil,forKey: getTextFieldName(value: caseLabelName))
} else {
textFieldValues.updateValue(textField.text,forKey: getTextFieldName(value: caseLabelName))
}
}
}
return textFieldValues
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)