hi,
i've a problem, i try to save strings i read since a fichier.txt file on the web, and save it into my iPhone, it's work fine, but when i call my saved file since another class, it's seems to be empty, here is my source code to save my file:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent
"random.txt"];
if([string writeToFile:filePath atomically:YES encoding:NSUTF16BigEndianStringEncoding error:NULL]){
NSLog(@"OK");
}
NSLog([NSString stringWithContentsOfFile:filePath encoding:NSUTF16BigEndianStringEncoding error:NULL]);
//this NLog work fine, i see my saved data.
And i want to read it since another class, here is my code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//NSString *path = [[NSBundle mainBundle] pathForResource:aPath ofType
"txt"];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent
"random.txt"];
NSString *string = [NSString stringWithContentsOfFile:filePath encoding:NSUTF16BigEndianStringEncoding error:NULL];
NSLog(string);
NSLog(@"Do am i here?");
Even the "Do am i here" does'nt work ... when i look the Console, i can see that to save my file, it switch task...i don't know how to do...please help...
i've a problem, i try to save strings i read since a fichier.txt file on the web, and save it into my iPhone, it's work fine, but when i call my saved file since another class, it's seems to be empty, here is my source code to save my file:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent
if([string writeToFile:filePath atomically:YES encoding:NSUTF16BigEndianStringEncoding error:NULL]){
NSLog(@"OK");
}
NSLog([NSString stringWithContentsOfFile:filePath encoding:NSUTF16BigEndianStringEncoding error:NULL]);
//this NLog work fine, i see my saved data.
And i want to read it since another class, here is my code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//NSString *path = [[NSBundle mainBundle] pathForResource:aPath ofType
NSString *filePath = [documentsDirectory stringByAppendingPathComponent
NSString *string = [NSString stringWithContentsOfFile:filePath encoding:NSUTF16BigEndianStringEncoding error:NULL];
NSLog(string);
NSLog(@"Do am i here?");
Even the "Do am i here" does'nt work ... when i look the Console, i can see that to save my file, it switch task...i don't know how to do...please help...