struct UserInfo : Codable {
let userId: String
}
...
let defaults = UserDefaults.standard
try defaults.set(object: UserInfo(userId: "id1"), forKey: "current-user")
let info = try defaults.get(objectType: UserInfo.self, forKey: "current-user")
- Swift 5 or above
CodableLocal is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CodableLocal'
bithavoc, im@bithavoc.io
CodableLocal is available under the MIT license. See the LICENSE file for more info.