개발/swift

Swift How to save data? Userdefaults

lemonade 2020. 10. 28. 10:00
반응형

How to save data in ios?

 

You can use UserDefaults to store any basic data type such as Bool, Float, Double, Int, String, or URL, 

but you can also write more complex types such as arrays, dictionaries and Date – and even Data values.
Note that data you saved in user defaults is gone when user delete app.
When you write data to UserDefaults, it automatically gets loaded when your app runs.

 

Let’s get started with user defaults.

First, create userdefault instance.

 

 

 

Second, save data you want to save. You can do this by using set method .

 

 


Finally, get saved data!

 

 

Noted, you can easily use user default by using set and get method.


Happy coding :)

 

반응형
그리드형

'개발 > swift' 카테고리의 다른 글

Swift mutating function  (0) 2020.11.01
Swift How to manage keyboard with UIScrollView?  (0) 2020.10.29
Swift How to set build environment?  (0) 2020.10.25
Swift UILabel linke break mode  (0) 2020.10.22
Swift divide result 0 issue  (0) 2020.10.20