嘿,我是 Swift 和 IOS 开发的新手。我面临一个搜索了很多的问题。但没有得到任何解决方案。我有 [String:AnyObject] 类型的字典,并希望将其分配给 [String:String] 类型的其他字典。Xcode 显示一个错误,即“致命错误:在展开可选 val 时意外发现 nil”我三倍检查没有 nil 值。下面是我的代码片段字典在这里
let dictFormData = ["name": endorsement.name,
"designation":endorsement.designation,
"location": endorsement.location,
"region": endorsement.region,
"effectiveDateString":endorsement.effectiveDate,
"marriageDateString": "ss" ,
"genderId": String(format: "%ld", selectedGenderLookUpId),
"relationId": String(format: "%ld", selectedRelationLookUpId),
"plan": "ss",
"employeeId": AICLPolicyModel.getSelectedPolicy()?.employeeID as Any,
"requestTypeId": 35,
"policyId": AICLPolicyModel.getSelectedPolicy()?.policyID as Any,
"isEmployee": isemployee,
"filePath":"ss",
"fileName": "ss",
"empRemarks": endorsement.remarks,
"hrRemarks": "ss",
"adminRemarks": "ss",
"memberCode": AICLPolicyModel.getSelectedPolicy()?.memberCode as Any,
"requestStatusId": 32,
"customerId": AICLPolicyModel.getSelectedPolicy()?.clientID as Any
]
这是将一个字典分配给另一个字典。
let formData = (dictFormData as? [String : String])!
在这一行它再次显示错误我很确定没有零值。