O'Reilly logo

iPhone JavaScript Cookbook by Arturo Fernandez Montoro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving and reading preferences

This recipe will teach you how to save and read values from the localStorage system. We're going to build a simple application for saving and reading a selected language as an internal preference. Actually, we'll ask the user to select one value for language and it will be stored in a property called lang. This property could be useful for deciding which other values should be used. In fact, the mentioned property helps us to choose and set another property in sessionStorage as you can learn in the next recipe of this chapter.

Obviously, you can store different properties in localStorage. This storage system can work as a central place for storing user's preferences avoiding the use of a local SQL-based database. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required