我使用NSKeyedArchiver将iPhone应用程序中的数据归档到.data中。长话短说,我丢失了所有的数据。我使用"iPhone back up extractor“,它工作得很好。我找到了我的应用程序的.data文件。
为了清楚起见,我发现了一个.data文件,我想打开它看看内容是什么样子的。据我所知,没有软件(例如记事本)能够读取该文件,我可能不得不使用Xcode。如果你知道任何方式,Xcode/notepad/某个程序,请让我知道。
这是我在构建应用程序时实现的代码:
- (NSString *)locPath {
return pathInDocumentDirectory(@"tableArray.data");
}
- (void)archieve{
// Get the path to the document directory
NSString *path = [self locPath];
// grab the array
NSMutableArray *tableArray = [someViewController tableArray];
// archive the array to file
[NSKeyedArchiver archiveRootObject:tableArray toFile:path];
}此代码在applicationWillTerminate、applicationDidEnterBackground等过程中调用。
在didFinishLaunchingWithOptions中恢复/调用数据的方式如下:
// Get the path to the document directory
NSString *path = [self locPath];
// Unarchive .data into an array
NSMutableArray *tableArray = [NSKeyedUnarchiver unarchiveObjectWithFile:path];如有任何帮助,我们不胜感激!谢谢!
PS:http://supercrazyawesome.com/是iPhone备份解压程序的链接
发布于 2011-06-29 11:29:07
我找到的最简单的方法是使用以下代码获取文档目录:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dir = [paths objectAtIndex:0];
NSLog(@"Directory: %@", dir);在那里,文档目录将包含.data文件
https://stackoverflow.com/questions/6297210
复制相似问题