Skip to content

Instantly share code, notes, and snippets.

@benbahrenburg
Created March 15, 2015 02:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbahrenburg/86d4870e2f7ec036937e to your computer and use it in GitHub Desktop.
Save benbahrenburg/86d4870e2f7ec036937e to your computer and use it in GitHub Desktop.
TIMOB-17458
1. Download Ti SDK https://github.com/benbahrenburg/titanium_mobile/tree/TIMOB-17458
or you can just patch by doing the following:
A) In your SDK open TiApp.m
B) add the following method
- (void)createDefaultDirectories
{
NSError* error = nil;
NSURL* dir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
inDomain:NSUserDomainMask
appropriateForURL:nil
create:YES
error:&error];
if(error)
{
DebugLog(@"[ERROR] %@ %@", error, [error userInfo]);
}
}
C) In the TiApp.m find the method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions_
D) At the end of the methd right before the return add [self createDefaultDirectories];
//To test the method use the following
var dir = Ti.Filesystem.getApplicationSupportDirectory();
console.log(dir);
var f = Titanium.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory);
console.log('Directory Exists: '+ (f.exists() ? 'Yes' : 'No'));
var testfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory, 'text.txt');
if(testfile.exists()){
testfile.deleteFile();
}
testfile.write("text written via write()\n");
console.log("Check file at:" + testfile.nativePath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment