Q: localStorage
I'm trying to make an iBook widget which has text fields and to store what those fields have in them to the local storage on the iPad. I have no HTML/JS/CSS knowledge at the moment (but am working on it). I want to be able to save the data automatically when closing the widget. If the book ever gets deleted, I want that data to be deleted as well. Is there an easy way round this? Thanks
iPad 2
Posted on Apr 24, 2013 10:14 PM
What I provided was a simplified example to illustrate the basics. You will need to store/retrieve every key value pair separately from localstorage. One way to do that would be to duplicate what I provided, but it would be more efficient to write a reusable function (beyond the scope of this discussion thread).
The basic code to clear a value for a key in localstorage is:
localStorage.removeItem(key);
Where "key" is a variable containing the string for your key. You could replace this with a literal string as I did in the previous example.
Coming up with a namespace scheme is a good idea too.
Posted on Apr 26, 2013 4:41 AM