User Defaults is great for storing client side settings in your app. Although we could achieve the same thing using Core Data or maybe even writing to a text file, with only a few lines of code we can save values and read values quite easily from User Defaults.
@glebserediuk46665 жыл бұрын
Thanks for the easy lesson but very valuable info hello from Ukraine ))
@CuriosMindDIY6 жыл бұрын
Awesome and very clear tutorial, now It makes total sense! I was just wondering, do sqlite and realm work with similar technique?
@CodePro6 жыл бұрын
Yeah they work in a similar fashion as far as where they are stored on the simulator / device. Typically if you use a SQLLite backed CoreData implementation it will save a .sqlite file on the file systems just like UserDefaults save a .plist file with the data.
@CuriosMindDIY6 жыл бұрын
Code Pro Thank you! You’re the man!
@CodePro6 жыл бұрын
Haha, no problem, glad it helped and good question :)
@stevengao83456 жыл бұрын
thanks for this tutorial, very clear to understand, but i do have a question that every time i use userdefault, do we need to use Userdefault.standard.synchronize( ) to end it ? not really sure why i use it at the first place, just i remember some article i read long time ago, since then i have kept using it every time i do user default, will cause a problem if i don't use it ? thanks
@CodePro6 жыл бұрын
This is a good question. The documentation is a little bit fuzzy from Apple. They actually say the method is unnecessary and should not be used. However, However I’m guessing this is a legacy API and Apple has never updated or deprecated this. I’ve also used the method right after setting something in user defaults and had no problem. I don’t think it matters much but if you are concerned there is no harm in using it.