gpt4 book ai didi

iphone - 用空字符串替换数组对象时出错

转载 作者:行者123 更新时间:2023-11-28 17:35:56 25 4
gpt4 key购买 nike

NSMutableArray 中的两个在索引 0 处具有相同值时出现不可预测的错误,然后我想删除该对象并用空字符串替换对象。但是应用程序崩溃说

 -[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0xe2a06b0
2012-03-22 14:36:48.181 golf eScorer[3849:11f03] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]:
unrecognized selector sent to instance 0xe2a06b0'

当我使用断点调试而不是日志显示时

2012-03-22 14:36:44.548 golf eScorer[3849:11f03] ArrayOfGameidOfPlayerToRemove....(
2
)
2012-03-22 14:36:44.549 golf eScorer[3849:11f03] discardedId...(
2
)

这是我的代码行:

 if([[ArrayOfGameidOfPlayerToRemove objectAtIndex:0] isEqualToString:[discardedId 
objectAtIndex:0]])
{
[ArrayOfGameidOfPlayerToRemove replaceObjectAtIndex:0 withObject:emptyString];
}

更新:

我是这样解决的

   NSMutableArray *ArrayOfGameidOfPlayerToRemove = [yournsarray mutableCopy];

最佳答案

似乎变量 ArrayOfGameidOfPlayerToRemoveNSArray 的实例。您只能在 NSMutableArray

中替换对象

关于iphone - 用空字符串替换数组对象时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9819220/

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