The best way to store data on iphone

I am creating a Q & A application for iphone that allows the user to answer the displayed questions.

I am currently invoking a web service to store user responses. But I'm a little worried that if the web service goes down. I need to store user responses locally and then start the web service when it starts.

How to save user responses when the web service is disabled. Is Sqllite a good option for this?

Please offer.

Thanks,

+1
source share
4 answers

Is Sqllite a good option for this?

Yes, SQLite is a great option. Another choice would be Core Data.

Use CoreData or SQLite on iPhone?

+4
source

It depends on the complexity of your data model. Recently, I have learned something like this, and here is what I learned. The most popular iPhone storage methods are:

  • Plist
    • Good for small amounts (hundreds of Ks) of hierarchical data.
    • It’s bad if the relationships or queries are complex (since you need to write code).
    • Very easy to learn .
    • Supports array, dict, string, data, date, integer, real, boolean.
    • You can save it as XML, which you can edit and transfer, or as binary files, which are faster.
  • Basic data
    • This is a graph manager of objects with search and permanent functionality.
    • You need a good few hours of training .
    • Easy to use if you configured it .
    • Better than plist because it allows you to manage graphs of objects, generate an object model, write queries, undo / redo, transfer changes to modified data models, manage memory and handle concurrent access.
    • Better than SQLite because:
      • Performance is similar, and development speed is faster.
      • Creating objects is faster.
      • When objects are in memory, query execution does not require a backend search (usually either memory or SQLite).
  • Sqlite
    • Database.
    • Better than basic data when the operation does not require you to add objects to memory. Example: update, delete and select 1 (see, If something exists).
    • It has a full text search if you compile the extension .
    • Harder to learn. Easier if you use a wrapper: FMDB , egodatabase .

If you can leave with plist, do it. If you see that the amount of code you have to write works too much, then switch to Core Data. Only if you are an expert and absolutely need performance , use SQLite (unless, of course, you already know SQLite, not Core Data).

+4
source

It must be yes. I created a Core Data-based application with Q&A objects and established relationships between them. Then just use the NSFetchedResultsController or whatever you would like to collect and display data

+1
source

You have several options:

  • Sqlite
  • Basic data
  • Client storage

If you want to go on a web route, I would take a quick look at the Safari Client-Side Programming and Standalone Applications Guide .

Basically you keep a local copy of the database in memory, so turn off the web service, users can still use the application.

+1
source

Source: https://habr.com/ru/post/894485/


All Articles