本文介绍了错误:“尝试使用appendString对不可变对象进行突变:"-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到一个错误尝试用appendString改变不可变对象:"
I am getting an error'Attempt to mutate immutable object with appendString:'
我的代码是
NSMutableString *resultString= [[NSMutableString alloc]init];
for (NSMutableString *s in self.ArrayValue)
{
[resultString appendString:s];
NSLog(resultString);
}
ArrayValue是NSMutableArray.
我不明白问题出在哪里
ArrayValue is NSMutableArray.
I am not able to understand where is the problem
先谢谢您
推荐答案
发布后,您拥有的代码不会给您所描述的错误.可能是在分配resultString和for循环之间的某个地方,您正在使用普通的NSSring覆盖它.
As posted, the code you have will not give you the error you describe. Probably, somewhere between allocating resultString and the for loop, you are overwriting it with a normal NSSring.
这篇关于错误:“尝试使用appendString对不可变对象进行突变:"-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!