tags:

views:

17

answers:

1
 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);

using this i can save data from my app to Documents folder right now sample1.cfg ia having 10 data now i want to add 10 more from web when user click on update button ?? so how to add 10 more data plz help

Thanks

A: 
...
NSData *dataXML = [NSData dataWithContentsOfURL:instructionsURLd];
NSMutableData *file = [[NSMutableData alloc] initWithContentsOfFile:storePath];
[file appendData:dataXML];
[file writeToFile:storePath atomically:YES];
...

This'll append the dataXML. If you want to prepend the data, use this:

...
NSMutableData *dataXML = [[NSData dataWithContentsOfURL:instructionsURLd] mutableCopy];
NSData *file = [[NSData alloc] initWithContentsOfFile:storePath];
[dataXML appendData:file];
[dataXML writeToFile:storePath atomically:YES];
...
Tim van Elsloo
perfect thanks a lot :-)
ram