Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 应用商店部署后出现错误,无法在临时部署中重新部署_Ios_Debugging_Nskeyedarchiver_Nscoding_Ad Hoc Distribution - Fatal编程技术网

Ios 应用商店部署后出现错误,无法在临时部署中重新部署

Ios 应用商店部署后出现错误,无法在临时部署中重新部署,ios,debugging,nskeyedarchiver,nscoding,ad-hoc-distribution,Ios,Debugging,Nskeyedarchiver,Nscoding,Ad Hoc Distribution,我的应用程序涉及用户保存我使用NSCoding/NSKeyedArchiver存储的数据。我在第一次运行应用程序时向用户提供示例数据对象 预期行为发生在定期测试期间,以及通过临时部署。不幸的是,当通过应用商店下载应用程序时,会出现一个严重的错误。 还有什么其他的环境因素可以让我在常规测试中重现(然后修复)这个问题 预期行为: 除当前数据对象外,新用户还可以添加/编辑数据对象。(典型的积垢情况) 实际行为: 如果用户的第一个操作是保存一个新对象,那么之前加载的所有示例对象都会消失(难以捉摸的bug

我的应用程序涉及用户保存我使用NSCoding/NSKeyedArchiver存储的数据。我在第一次运行应用程序时向用户提供示例数据对象

预期行为发生在定期测试期间,以及通过临时部署。不幸的是,当通过应用商店下载应用程序时,会出现一个严重的错误。

还有什么其他的环境因素可以让我在常规测试中重现(然后修复)这个问题

预期行为:

除当前数据对象外,新用户还可以添加/编辑数据对象。(典型的积垢情况)

实际行为:

如果用户的第一个操作是保存一个新对象,那么之前加载的所有示例对象都会消失(难以捉摸的bug)。 但是,如果用户的第一个操作是编辑,那么所有对象都会按照预期的方式保留,用户可以添加其他对象而不会出现问题

谢谢你的帮助

编辑

在我最近的测试中,我在“运行”方案中将构建配置切换为发布

应用程序委托,它正确初始化应用程序

对象创建,如果数据尚未编辑,则删除预加载的数据


我猜在保存新对象时,您没有将其附加到现有数据。您可能过度写入了以前创建的文件。您应该访问上一个文件,并将新数据附加到上一个文件中。共享代码将有助于指出错误所在

编辑:替换以下代码并检查其是否仍显示相同的行为

-(void)viewDidLoad {
    tempArray = nil;
    tempArray = [NSKeyedUnarchiver unarchiveObjectWithFile:[AppDelegate getDocPath]mutableCopy];
    if (tempArray == nil) {
        NSLog(@"tempArray is nil"); //if tempArray doesn't get initialized by the file contents  
        tempArray = [[NSMutableArray alloc] init];

    }   
}

我不知道如何解决您当前的问题(不看代码),但以下是您将来可以避免的方法:

确保您提交给应用商店的构建是经过QA认证但使用应用商店配置文件签名的临时构建

两个优点: 1) 您应该能够在adhoc和appstore构建中重新编写相同的bug
2) 这两者的dSym是相同的。因此,您不必等待获取AppStore崩溃日志,然后才能深入查看发生了什么。

您可以共享添加和编辑任务的代码吗?两者在与文件系统交互的方式上肯定有一些不同。仅举一个例子,add方法可能会创建一个与包含示例文件的目录同名的文件。您有哪些环境设置?调试,发布,ifdef的…添加了代码以及一些方案设置的屏幕截图。你知道为什么它们会阻止这个bug被复制吗?有没有任何预处理器宏会在发布时改变你应用程序的流程(或目标服务器)?谢谢Calvinbai。是的,在organizer中,我临时分发了我最初提交给app store的相同档案。可悲的是,这并没有带来什么不同。
-(void)viewDidLoad {
    tempArray = nil;
    tempArray = [NSKeyedUnarchiver unarchiveObjectWithFile:[AppDelegate getDocPath]];
    if (tempArray == nil) {
        tempArray = [[NSMutableArray alloc] init];  
    }   
}

-(void)saveObject {
    [tempArray addObject:createdData];
    [tempArray sortUsingSelector:@selector(compare:)];
    NSString *path = [AppDelegate getDocPath];
    [NSKeyedArchiver archiveRootObject:tempArray toFile:path];
    AppDelegate *dg = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    dg.dataArray = tempArray;
}
-(void)viewDidLoad {
    tempArray = nil;
    tempArray = [NSKeyedUnarchiver unarchiveObjectWithFile:[AppDelegate getDocPath]mutableCopy];
    if (tempArray == nil) {
        NSLog(@"tempArray is nil"); //if tempArray doesn't get initialized by the file contents  
        tempArray = [[NSMutableArray alloc] init];

    }   
}