我有一個應用程序在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