-
-
Save marchon/867125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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