【发布时间】:2014-12-09 20:24:46
【问题描述】:
堆栈溢出:
我需要帮助。我在应用商店中有一个应用,它收集用户输入(文本)并将其保存到应用沙箱的 Documents 文件夹中的存档文件(NSKeyedArchiver)中。数据在通过 NSKeyedUnarchiver 启动时进行翻新。此过程在多次更新中运行良好。我刚刚向 iTunes Store 发布了应用程序的更新,有人声称他们的数据已丢失。我的问题是我无法重现失败。
我现在拥有 iPhone 和 iPad 版本的应用程序,在 iPhone 版本中,我将旧文件名重命名为 iPad 使用的相同名称;这是在 didFinishLaunchingWithOptions 中完成的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
. . .
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// get full path to Document subdirectory
NSString *documentFolder = [paths objectAtIndex:0];
// form full path for both old and new archive filenames
self.archiveFile = [documentFolder stringByAppendingPathComponent:oldArchiveName];
NSString *newArchive = [documentFolder stringByAppendingPathComponent:newArchiveName];
NSLog(#” *** self.archiveFile (%@)”,self.archiveFile);
NSLog(#” *** newArchive (%@)”,newArchive);
// let’s rename the archive
NSFileManager *fm = [NSFileManager defaultManager];
// if the old archive filename exists change it to the new name
if([fm fileExistsAtPath:self.archiveFile])
(void)[fm moveItemAtPath:self.archiveFile toPath:newArchive error:nil];
// self.archiveFile now points to the new archive file
self.archiveFile = newArchive;
NSLog(#” *** self.archiveFile (%@)”,self.archiveFile);
. . .
}
从 Xcode 设备窗口的控制台子窗口:
10 月 14 日 14:02:46 Randy-Merritts-iPad phoneFilebox[11096]: *** self.archiveFile (/var/mobile/Containers/Data/Application/3BF0757B-96F4-4AAA-9CEB-6C87505CA6BD/Documents/cabself.xobeliF)
10 月 14 日 14:02:46 Randy-Merritts-iPad phoneFilebox[11096]: *** newArchive (/var/mobile/Containers/Data/Application/3BF0757B-96F4-4AAA-9CEB-6C87505CA6BD/Documents/iFilebox.cabinet)
10 月 14 日 14:02:46 Randy-Merritts-iPad phoneFilebox[11096]: *** self.archiveFile (/var/mobile/Containers/Data/Application/3BF0757B-96F4-4AAA-9CEB-6C87505CA6BD/Documents/iFilebox.cabinet)
来自我的用户的投诉表明该应用尝试打开“self.archiveFile”失败(如果在文档中未找到存档,则表示您是新用户,我创建了一个空存档准备接收新数据)。问题是:它对我来说永远不会失败。此外,安装新更新后,您可以输入新数据、终止应用程序、重新启动应用程序,所有(新)数据都在那里。如果我解压数据的方式存在编程缺陷,这种失败不会重复吗?
我使用 Xcode 6.0.1 设备窗口安装新版本以及 www.diawi.com 将测试版本分发给团队成员,我们都没有丢失任何数据;注意这两种方法严格执行更新;他们不会(也没有任何理由)干扰 Documents 子目录。
但是,我们可以通过从 App Store 下载副本来重现数据丢失问题。 App Store 下载/设备内应用更新过程似乎正在重置 Document 文件夹并删除任何以前的文件。
有人看过吗?有人知道这个问题吗?为什么要从 App Store 安装升级版
【问题讨论】:
-
还有一项。我需要在 plist 文件中设置什么吗?权利文件?分布概况?我应该包括任何其他文件吗?
标签: iphone installation store