Prephirences
Prephirences copied to clipboard
store struct not working
I'm trying to store struct object but not work.
struct InstagramApiUser: Codable {
var access_token: String
var user_id: Int
}
storing with:
let json = try JSONDecoder().decode(InstagramApiUser.self, from: data)
KeychainPreferences.sharedInstance[InstagramClient.keychain_api_user_key, .archive] = json
retrieving with:
if let user = self.keychain.object(forKey: InstagramClient.keychain_api_user_key) as? InstagramApiUser {
print("- OAuth2 user api: \(String(describing: self.user_api))")
}
hi have you add a breakpoint, see the value returned by object function? (maybe before read the code...)
https://github.com/phimage/Prephirences/blob/3a42074d540c09018cd0699eced43905847a2381/Sources/PrephirenceType%2BCodable.swift#L2