Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created August 29, 2011 15:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aaronksaunders/1178624 to your computer and use it in GitHub Desktop.
test harness for Titanium Appcelerator Quickie: base64encode iOS Module
// This is a test harness for your module
// You should do something interesting in this harness
// to test out the module and to provide instructions
// to users on how to use it by example.
// open a single window
var window = Ti.UI.createWindow({
backgroundColor:'white'
});
var label = Ti.UI.createLabel();
window.add(label);
window.open();
// TODO: write your module tests here
var utils = require('com.clearlyinnovative.utils');
Ti.API.info("module is => " + utils);
var f = Ti.Filesystem.getFile("allgood.png");
Ti.API.info(utils.base64encode( f.read() ));
var encoded_string = utils.base64encode( f.read() );
var newDir = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'mydir');
Ti.API.info("Created mydir: " + newDir.createDirectory());
Ti.API.info('newdir ' + newDir.nativePath);
var newFile = Titanium.Filesystem.getFile(newDir.nativePath,'newfile.png');
newFile.write(Ti.Utils.base64decode(encoded_string));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment