Prephirences icon indicating copy to clipboard operation
Prephirences copied to clipboard

store struct not working

Open niskah-media opened this issue 1 year ago • 1 comments

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))")
         } 

niskah-media avatar Sep 07 '24 18:09 niskah-media

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

phimage avatar Sep 07 '24 18:09 phimage