Hi all,
I want to load all data from multiple json files exposed by an ASP.net web service at startup of the mobile app and store them into arrays for the duration of the application. All tableViews should retrieve their data from these arrays. What is the best way to do this?
Your response is much appreciated. An example would be very helpful.
Thanks in advance!
Application type: mobile Titanium SDK: 2.0.2 Platform & version: iOS 5.1 Device: iPad Only
1 Answer
I do something similar.
In your app.js, before loading your main window:
var appData; var appXhr = Ti.Network.createHTTPClient({ onload : function (e) { appData = JSON.parse(this.responseText); startHome(appData); // display the start/home screen }, onerror : function (e) { HandleNetworkError(e); }, timeout: 15000 }); appXhr.open('GET', 'http://yourserver.com/get.app.data/'); appXhr.send();The startHome function will display the main window, etc. Doing it this way keeps your splash screen up while you are grabbing the data and will then display the main window once the XHR has returned. All your appData is now accessible as a global object throughout your app (you might want to put it within a global namespace for best practices sake).
Your Answer
Think you can help? Login to answer this question!