我需要将值typeUser和userId存储在NSUserDefaults中。但是它将错误显示为“'尝试为键TypeUser插入非属性列表对象1'”。我没有在Swift 4中找到合适的解决方案。代码如下:
let Response = (responseInfo as AnyObject) as! NSDictionary
print("Userid" ,Response)
let typeUser = Response.value(forKey:"type")!
let userId = Response.value(forKey: "id")!
print("typeUser",typeUser)
print(userId)
UserDefaults.standard.set(typeUser , forKey: "TypeUser")
UserDefaults.standard.synchronize()
UserDefaults.standard.set(userId , forKey: "UserId")
UserDefaults.standard.synchronize()