gpt4 book ai didi

iphone - 由于未捕获的异常 'NSGenericException' 终止应用程序,原因 : '*** Collection was mutated while being enumerated

转载 作者:行者123 更新时间:2023-12-01 16:53:49 24 4
gpt4 key购买 nike

有时我的应用程序因显示 * Collection 在被枚举时发生了变异而崩溃。这一直发生在同一行代码中。请帮助我解决这个问题。我坚持这一点。该应用程序在推送我的代码的 View Controller 行时崩溃。但这并不常见。我的错误控制台

由于未捕获的异常“NSGenericException”而终止应用程序,原因:“* Collection CALayerArray: 0x1030c730 在枚举时发生了突变。
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
“”
)'

我的代码:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ServiceDetails *service=[[ServiceDetails alloc] initWithNibName:@"ServiceDetails" bundle:nil];
CompanyListingForm *list=[[CompanyListingForm alloc]initWithNibName:@"CompanyListingForm" bundle:nil];
[category_company_text resignFirstResponder];
if(viewHoldingTable)
{
[viewHoldingTable removeFromSuperview];
}
if (category_clicked_flag==0) {
if (location_or_cat_com==0) {
NSMutableArray *get=[district_array objectAtIndex:indexPath.row];
locationid=[[get objectAtIndex:0]intValue];
[location_textfield resignFirstResponder];
location_textfield.text=[get objectAtIndex:1];
}
else
{
if (draggingView) {
[draggingView removeFromSuperview];

}
if (viewHoldingTable) {
[viewHoldingTable removeFromSuperview];
}


NSMutableArray *get=[company_array objectAtIndex:indexPath.row];
category_company_text.text=[get objectAtIndex:1];



service.ida=[NSString stringWithFormat:@"%d",[[get objectAtIndex:0] intValue]];

service.idloc=[NSString stringWithFormat:@"%d",locationid];



[self.navigationController pushViewController:service animated:YES];//getting error at this point.

//[emer release];
}
}
else
{
if (location_or_cat_com==0) {
NSMutableArray *get=[district_array objectAtIndex:indexPath.row];
locationid=[[get objectAtIndex:0]intValue];
[location_textfield resignFirstResponder];
location_textfield.text=[get objectAtIndex:1];
}
else
{
NSMutableArray *get=[category_array objectAtIndex:indexPath.row];
category_company_text.text=[get objectAtIndex:1];
int catid=[[get objectAtIndex:0]intValue];

list.IDForLoc=[NSString stringWithFormat:@"%d",locationid];
list.IDForCat=[NSString stringWithFormat:@"%d",catid];
list.companydetails=[get objectAtIndex:1];
[self.navigationController pushViewController:list animated:YES];//getting error at this point.

}
}
[service release];
[list release];
}

最佳答案

我认为问题在于您在要求推送 View Controller 的同时对界面执行所有这些操作。尝试包装 pushViewController dispatch_after 中的一行 block ,例如延迟 0.1 秒,以使接口(interface)的其他更改有时间稳定下来。或者换一种方式:把 removeFromSuperview东西变成延迟。更好的是,抛出某种标志,以便稍后在 viewWillAppear 上删除要从 super View 中删除的内容。 .您现在不需要这样做;无论如何,您将要隐藏以使用推送的 View Controller 覆盖此 View 。

关于iphone - 由于未捕获的异常 'NSGenericException' 终止应用程序,原因 : '*** Collection <CALayerArray: 0x66522e0> was mutated while being enumerated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13577486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com