Smooth NSUserDefault handling with Swift

If there’s something that I love about swift it would be for sure the enums; so when I have some free time, I like to see what cool stuff I can achieve with them.

Today I want to share with you some a really simple code for handling the writing and the reading on UserDefault.

This code is so easy that anybody can understand;

  • get() → read from UD
  • set() → write on UD
  • remove() → delete from UD
  • Add a new field just by adding a new case

I hope you find this little trick interesting :)