Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.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:无法将阵列实例复制到其他阵列_Iphone_Core Data - Fatal编程技术网

iphone:无法将阵列实例复制到其他阵列

iphone:无法将阵列实例复制到其他阵列,iphone,core-data,Iphone,Core Data,不知道为什么会发生这种情况我有一个方法getOutput,它返回一个托管对象数组 NSArray *fetchedOutages = [context executeFetchRequest:fetchRequest error:&error]; if (error) { NSLog(@"Error in Core Data: %@", [error description]); } return fetchedOutages; 当我尝试将此数组复制到ListOutput时(这

不知道为什么会发生这种情况我有一个方法getOutput,它返回一个托管对象数组

NSArray *fetchedOutages = [context executeFetchRequest:fetchRequest error:&error];
if (error) {
    NSLog(@"Error in Core Data: %@", [error description]);
}
return fetchedOutages;
当我尝试将此数组复制到ListOutput时(这是一个属性)

我试着像这样在didRowSelectMethod中复制这个数组

if (listOutage) {
        NSLog(@"Its there");
        [listOutage release];
    }

    listOutage=[[NSArray alloc] initWithArray:[self getOutage]];
我尝试了其他各种方法,但都失败了

此GetOutput方法返回5个对象ListOutput中复制的5个对象,但当我尝试访问ListOutput元素时,它们显示为“超出范围” 请帮助我克服这个问题,我必须将它传递给下一个ViewController


提前感谢

如果有属性,请使用“self.property”而不是“property”,这样,当其他人阅读您的代码时,如果您指的是ivar或属性,则更明显

如果使用self.property,则不需要编写

if (listOutage) {
        NSLog(@"Its there");
        [listOutage release];
    }

    listOutage=[[NSArray alloc] initWithArray:[self getOutage]];
相反,只需写

NSArray newListOutage=[[NSArray alloc]  initWithArray:[self getOutage]];
self.listOutage = newListOutage;
[newListOutage release];
释放和保留将由@synthesis属性生成的get/set方法处理

NSArray newListOutage=[[NSArray alloc]  initWithArray:[self getOutage]];
self.listOutage = newListOutage;
[newListOutage release];