Ilan Kutsman
Ilan Kutsman

Reputation: 469

Storing info locally without using NSUserDefaults

I was wondering whether there are any other ways in swift to save data locally on device, which will be available also after app close without using NSUserDefaults.

If there are, in which cases is that specific solution preferable?

I know this is kind of general, but I know just this one way to do saving locally and from my experience, there is always more than one way to do something(unless there isn't). Any answers would be greatly appreciated

Upvotes: 1

Views: 67

Answers (1)

Nikita Kurtin
Nikita Kurtin

Reputation: 6237

Yes there are different ways to store data locally.

As you have mentioned one of them is NSUserDefaults

In addition to that you can also:

  1. Use files such as plist, JSON or your own custom format.

  2. Use Core Data

  3. Use SQLite

    And also you can combine between those.

Here some nice post Core Data VS SQLite

Now for:

in which cases is that speciffic solution preferable

I would say that NSUserDefaults is good when you need to store some small pieces of data, for example: Numbers, Booleans, Strings.

Upvotes: 1

Related Questions