Dinesh Katwal Dinesh Katwal - 1 month ago 22
Swift Question

How to make realtime database like firebase for my app in swift ios?

I am getting problem in consuming

RestAPI
and saving offline data. Is any one have best ideas about this.

I want to save JSON response from server in local database and use that data when no internet is available. like
Firebase
realtime Database.

Answer

I think what are you asking for is a mechanism to persist data into your application. There are several approaches to achieve this, you might want to check:

Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence.

The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an application to customize its behavior to match a user’s preferences. For example, you can allow users to determine what units of measurement your application displays or how often documents are automatically saved. Applications record such preferences by assigning values to a set of parameters in a user’s defaults database. The parameters are referred to as defaults since they’re commonly used to determine an application’s default state at startup or the way it acts by default.

SQLite is a relational database management system contained in a C programming library. In contrast to many other database management systems, SQLite is not a client–server database engine. Rather, it is embedded into the end program.

Wikipedia resource.

Realm Mobile Database is an alternative to SQLite and Core Data. Thanks to its zero-copy design, Realm Mobile Database is much faster than an ORM, and often faster than raw SQLite. Get started in minutes, not hours.

Hope this helped.