|
I am trying to save the user details to preference as below
But the NSKeyedUnarchiver.unarchivedObject(ofClass:) is throwing error. "The data couldn’t be read because it isn’t in the correct format"
And EVObject is NSCoding Can anyone please suggest solution for this. |
|
Hi! I think the problems in that:
|
|
This is for decoding:
this is for encoding:
sorry for any typos though :) but the idea is like that. Just modify for your do catch block |
|
Thank you for helping me. I changed the code as below.
It works as expected. Hope this is correct. |
|
If you are using just UserDefaults and there is not specific purpose for you to use NSKeyedArchiver and NSKeyedUnarchiver. I suppose you can even boil down to something like this:
|
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.