Skip to content

Instantly share code, notes, and snippets.

@marchon
Forked from itspriddle/ti.datastore.js
Created March 12, 2011 08:09
Show Gist options
  • Save marchon/867125 to your computer and use it in GitHub Desktop.
Save marchon/867125 to your computer and use it in GitHub Desktop.
var $CONFIG = function(key, value) {
if (arguments.length == 2) {
if (value === null) {
Ti.App.Properties.removeProperty(key);
} else {
Ti.App.Properties.setString(key, JSON.stringify(value));
}
} else if (arguments.length == 1) {
var data = Ti.App.Properties.getString(key, false);
return data && JSON.parse(data) || undefined;
}
};
// Set config item
$CONFIG('user', { name: 'Josh', username: 'itspriddle' });
// Get config item
var current_user = $CONFIG('user');
// Delete config
$CONFIG('user', null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment