Tuesday, August 10, 2010

saving locaaly and update data from web

#pragma mark save file locally


NSString *applicationDocumentsDir =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:@"sample1.cfg"];

NSURL *instructionsURLd = [[NSURL alloc] initFileURLWithPath:filePath];
NSData *dataXML = [NSData dataWithContentsOfURL:instructionsURLd];

[dataXML writeToFile:storePath atomically:YES];

// NSLog(@"matrix path %@",applicationDocumentsDir);
//NSLog(@"neo path %@",storePath);



#pragma mark update
// http://localhost/update.cfg

//NSData *dataXML = [NSData dataWithContentsOfURL:instructionsURLd];

NSURL *urlf = [[NSURL alloc] initWithString:@"http://localhost/update.cfg"];
dataXML = [NSData dataWithContentsOfURL:urlf];


NSMutableData *file = [[NSMutableData alloc] initWithContentsOfFile:storePath];
[file appendData:dataXML];
[file writeToFile:storePath atomically:YES];

No comments:

FEEDJIT Live