我有一个应用程序在XCode模拟器(v6.4)中运行;这是相关代码:writeToFile失败,错误= null
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
// read the file back into databuffer...
NSFileHandle *readFile = [NSFileHandle fileHandleForReadingAtPath:[documentsPath stringByAppendingPathComponent: @"Backup.txt"]];
NSData *databuffer = [readFile readDataToEndOfFile];
[readFile closeFile];
// compress the file
NSData *compressedData = [databuffer gzippedData] ;
// Write to disk
NSString *outputPath = [NSString stringWithFormat:@"%@/%@%@.zip", documentsPath, venueName, strDate];
_BackupFilename = fileName; // save for upload
NSFileHandle *outputFile = [NSFileHandle fileHandleForWritingAtPath:outputPath];
NSError *error = nil;
// write the data for the backup file
BOOL success = [compressedData writeToFile: outputPath options: NSDataWritingAtomic error: &error];
if (error == nil && success == YES) {
NSLog(@"Success at: %@",outputPath);
}
else {
NSLog(@"Failed to store. Error: %@",error);
}
[outputFile closeFile];
我试图通过采取文件,压缩它,然后写出来,以创建一个文件的备份。我收到一个错误无法存储。错误:(null));为什么它没有返回错误代码失败?
嗨Rick ...输出文件用作“恢复”功能的输入...我会做出更改并回复给您... 注意:我刚刚保存了我的评论,现在全部你的消失了吗?我如何让他们回来? – SpokaneDude