gpt4 book ai didi

ios - "Collection ... mutated while being enumerated"崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:56:32 38 4
gpt4 key购买 nike

崩溃后出现此错误:

malloc: *** error for object 0x75617b4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
2013-02-05 19:15:44.950 BusinessIdea[3171:15e03] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSSetM: 0x72dc5c0> was mutated while being enumerated.'

我不熟悉这个错误。知道它可能是什么吗?

最佳答案

整个“在枚举时修改”错误意味着您可能在迭代时尝试从集合中删除某些内容。例如

for(NSString *str in array){
if([str isequalToString:@"delete me"]){
[array removeObject:str]; //this will cause a problem,
}
}

如果要使用快速枚举循环,则需要构建一个要删除的项目列表,然后在迭代步骤后删除它们。如果要删除循环体中的项目,替代方法是使用传统的索引 for 循环。

关于ios - "Collection ... mutated while being enumerated"崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14719447/

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