Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.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
Iphone n内部一致性异常原因:'-[\uu NSCFArray replaceObjectAtIndex:withObject:]:发送到不可变对象的mutating方法';_Iphone_Ios - Fatal编程技术网

Iphone n内部一致性异常原因:'-[\uu NSCFArray replaceObjectAtIndex:withObject:]:发送到不可变对象的mutating方法';

Iphone n内部一致性异常原因:'-[\uu NSCFArray replaceObjectAtIndex:withObject:]:发送到不可变对象的mutating方法';,iphone,ios,Iphone,Ios,请您帮助我解决以下错误: 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“-[\uu nsFarray replaceObjectAtIndex:withObject:::正在将方法发送到不可变对象” array_Info = [[NSMutableArray alloc] init]; array_Info = [dict_Temp objectForKey:@"Children"]; NSMutableArray *temp =

请您帮助我解决以下错误:

由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“-[\uu nsFarray replaceObjectAtIndex:withObject:::正在将方法发送到不可变对象”

array_Info = [[NSMutableArray alloc] init];
array_Info = [dict_Temp objectForKey:@"Children"];

NSMutableArray *temp = [[NSMutableArray alloc] initWithArray:self.array_Info];

            int ran, arrayIndexing = 0;
            while ([temp count] != 0)
            {
                ran = arc4random();
                if(ran < 0)
                    ran*=-1;
                ran = ran % [temp count];

                if([temp count] == 1)
                    ran = 0;

                NSLog(@"%d  %d",arrayIndexing,ran);

                [self.array_Info replaceObjectAtIndex:arrayIndexing withObject:[temp objectAtIndex:ran]];

                [temp removeObjectAtIndex:ran];
                arrayIndexing++;
            }
array_Info=[[NSMutableArray alloc]init];
数组_Info=[dict_Temp objectForKey:@“Children”];
NSMutableArray*temp=[[NSMutableArray alloc]initWithArray:self.array_Info];
int-ran,arrayIndexing=0;
而([temp count]!=0)
{
ran=arc4random();
if(ran<0)
ran*=-1;
ran=ran%[临时计数];
如果([临时计数]==1)
ran=0;
NSLog(@“%d%d”,数组索引,已运行);
[self.array_Info replaceObjectAtIndex:arrayIndexing with object:[temp objectAtIndex:ran]];
[临时删除对象索引:ran];
arrayIndexing++;
}

似乎
self.array\u Info
是一个不可变的数组。使其可变。

似乎
self.array\u Info
是一个不可变的数组。使其可变。

假定
array\u Info
self.array\u Info
属性的支持变量,您应该将第二行更改为:

array_Info = [[dict_Temp objectForKey:@"Children"] mutableCopy];

这将为
replaceObjectAtIndex:withObject:
调用提供所需的可变数组。

假定
array\u Info
self.array\u Info
属性的支持变量,则应将第二行更改为:

array_Info = [[dict_Temp objectForKey:@"Children"] mutableCopy];

这将为您提供
replaceObjectAtIndex:withObject:
调用所需的可变数组。

这并不能使它成为可变数组,您只是在它上面写。在数组上使用mutableCopy。@DeepakR声明无关紧要。Objective-C是动态的。您能推荐一些示例代码吗?我尝试了很多方法,但仍然没有找到解决方案。@DeepakR
self.arrayInfo=[NSMutableArray new]这并不能使它成为一个可变数组,你只是在它上面写。在数组上使用mutableCopy。@DeepakR声明无关紧要。Objective-C是动态的。您能推荐一些示例代码吗?我尝试了很多方法,但仍然没有找到解决方案。@DeepakR
self.arrayInfo=[NSMutableArray new]