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);
使用此我可以立即将数据从我的应用程序保存到Documents文件夹 sample1.cfg 现在有10个数据我想在用户点击更新按钮时从网上再添加10个? 所以如何添加10个数据plz帮助
由于
答案 0 :(得分:0)
...
NSData *dataXML = [NSData dataWithContentsOfURL:instructionsURLd];
NSMutableData *file = [[NSMutableData alloc] initWithContentsOfFile:storePath];
[file appendData:dataXML];
[file writeToFile:storePath atomically:YES];
...
这将附加dataXML。如果要预先添加数据,请使用:
...
NSMutableData *dataXML = [[NSData dataWithContentsOfURL:instructionsURLd] mutableCopy];
NSData *file = [[NSData alloc] initWithContentsOfFile:storePath];
[dataXML appendData:file];
[dataXML writeToFile:storePath atomically:YES];
...