Creating an Extension and Property Wrapper For UserDefaults in Swift

Before we start making an extension and a property wrapper for UserDefaults, first I want to talk about what those are.

What is UserDefaults:

If you want to save some simple things in your storage, for example, if the user has closed a screen or not yet, you can keep this information on UserDefaults. The short definition should be like this: UserDefaults is a .plist file in your app’s package. You use it to set and get simple data. It’s structure is similar to a dictionary, you can get and…

S.O.L.I.D is an acronym for five design principles by Robert C. Martin (Uncle Bob).These principles, when combined, make it easy for a programmer to develop software that is easy to maintain and extend. By using these, developers can avoid code smells, easily refactor their codes and keep their code quality high.

S.O.L.I.D stands for:

  • S — Single-responsibility
  • O — Open-closed
  • L — Liskov substitution
  • I — Interface segregation
  • D — Dependency Inversion

Let’s look at each category separately and discuss its characteristics and you’ll see how they can make your code cleaner.

Single Responsibility Principle:

Each software module should…

Tigran Mirijanyan

Male

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store