Good day community! Inevitably, the day is approaching when I will have to learn how to save data (any) for a certain time using the Swift language. Could you tell me how (the main String from TextField!), Or direct my searches in the right direction ... I understand that you need to raise the database and process it using certain methods ... Through UserDefaults.standard I can save only one “set” of which, of course, is not enough ...

  • What exactly should be saved? why userDefaults is not suitable? - Max Mikheyenko
  • I save three Strings there, but for some reason when I write down a "new set" of three Strings, the first 3 lines are replaced with the new three. Maybe I'm doing something wrong? I can give an example of my code if necessary. Besides, after OS X restart, data is also lost ... - Igor Zexyy
  • What does one set mean? A set of what? You say at the beginning that you want to save the string. - VAndrJ
  • Yes, I want to save the string and I save it (it persists even after restarting the XCOD), but it is overwritten with another string if I try to save the second one. In this case, the last recorded line is lost after the OS X restart. - Igor Zexyy
  • I would like to write them for a long time (until I decide to remove them) with the ability to write down new lines. - Igor Zexyy

1 answer 1

When you use UserDefaults you can save one value for one key there. You can go to the trick and make an array of strings and save it in UserDefaults . But I would advise to use Core Data to store various data. But it all depends on your goals.