我使用 NSKeyedArchiver 将 iPhone 应用程序中的数据归档到 .data 中。长话短说,我丢失了所有数据。我使用“iPhone 备份提取器”,效果很好。我为我的应用找到了一个 .data 文件。
为了清楚起见,我找到了一个 .data 文件,我会打开并查看其内容。我知道没有软件(例如:记事本)可能能够读取该文件,我可能不得不使用 Xcode。如果您知道任何方式,Xcode/notepad/someProgram,请告诉我。
这是我在构建应用程序时实现的代码:
- (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:iPhone 备份提取器的链接是http://supercrazyawesome.com/