Generic UserDefaults wrapper
Sep 7, 2018 · 1 min read

In my previous article I described how to create generic class for storage Realm objects. But what if we don’t want to use such advanced libraries and keep data in UserDefaults. We could also use generic class. It sounds so cool.
At the beginning, like usual, we must create our protocol
And implement it for our storage class
And that’s it. Now we could read or write not only primitives but also any class conforms to a Storage protocol. You want some example? Below you have more complex object.
And here you have full example
Thank you for reading! If you liked this article, please clap so other people can read it too. I will also have more motivation for next article :) You can also see my other articles, maybe you will find something for you.
If you have any question or suggestion leave a comment.
