How to save Data from HTTPRequest for offline use

  1. 3 years ago


    21 Jun 2017 User since 2017

    Hello Creo's

    I need to load data from HTTPRequest (for example from Spotify) and make it available when device offline
    maybe we could use HTTPRequest than SQLite to save data but I need to know how we connect them together

    Thanks in advance

  2. marco

    10 Jul 2017 Administrator User since 2016

    Hi @Roayati can you please let us know what kid of data are you trying to get from Spotify?

  3. Roayati

    11 Jul 2017 User since 2017

    I need to save song information such us (name, artist, album .. etc) and save to for Offline use

  4. 2 years ago


    24 Jul 2017 User since 2017

    @marco ?!

  5. marco

    24 Jul 2017 Administrator User since 2016

    You can save all that information in a sqlite database.
    Do you have a sample project to show me?

  6. Roayati

    26 Jul 2017 User since 2017

    @marco I have attached iTunes search, I need to save data as offline , so whenever I open app in offline it show the data

    Thanks @marco

  7. Roayati

    30 Jul 2017 User since 2017

    @marco !?

  8. marco

    1 Aug 2017 Administrator User since 2016
    Edited 2 years ago by marco

    In Request -> NewValue event write the following code:

    var n = value["resultCount"];
    var r = value["results"];
    for (var entry in r) {
    	var artistId = entry["artistId"];
    	var artistName = entry["artistName"];
    	var trackName = entry["trackName"];
    	Console.write("\(artistName) \(trackName)");

    entry is a dictionary extracted from the JSON result set, and each key of the dictionary corresponds to the key of the JSON result (that you can see from the preview panel).

    Once you extracted the fields you are interested on then you can serialise them to an sqlite database and then reuse it when network connection if off.

    Please note that in order to trigger the NewValue event one the simulator you have to pull to refresh the tableView (issue will be fixed in the next version). This trick is not necessary on a real device.

or Sign Up to reply!