字典键显示为硬编码字符串,因此搜索了删除它的最佳方法。
let sentObj : [String:Any] = [
"id": Int(objData["_id"] as! String)!,
"boolPresentValue": "234",
"compositePropertiesString":objData["compositePropertiesString"]!
]
我们使用的方法是创建一个私有结构,保留所有字符串文字并使用它。
类似
private struct ViewControllerCosntants {
static let category = "Category"
static let rating = "Rating"
static let currentNav = "Current Nav"
static let type = "Type"
}
并像]一样使用它>
ViewControllerCosntants.category
我需要的地方。
dict.removeValue(forKey: willRemoveKey)