我尝试使用Core数据迭代从SQLite数据库获取的数据。我将所有从CoreData中获取的数据存储在NSMutableArray
中。当我在这个数组中使用for循环迭代时,我只能得到数组中的第一个元素,但是元素的其余部分会给我这个错误:
<Task: 0xf18b390> (entity: Task; id: 0xf18a700 <x-coredata://7388F0B7-E583-4BF0-BE64-08AD014EC583 /Task/p104> ; data: <fault>
在我正在使用的代码下方:
dispatch_sync(classificationQueue, ^{
NSMutableArray *waitingTasks = [[NSMutableArray alloc]initWithArray:[self getInsepectorTaskByTaskStatus:managedObjectContext :TASKSTATUSWAITING:CLASSIFICATIONFORMTYPE]];
for (Task *cTask in waitingTasks){
//Here when print cTask nsmanagedobject get me fault data
NSLog(@"BBBBBBB %@",cTask);
corporateName = [[NSString alloc]initWithString:(classificationWaitingTask.corporate.corporateTitle?classificationWaitingTask.corporate.corporateTitle:@"-")];
[self performSelector:@selector(sendingClassificationForm:) withObject:classificationWaitingTask];
sleep(0);
}
}
答案 0 :(得分:0)
这是解决发生的数据:错误
NSFetchRequest *taskDataRequest = [[NSFetchRequest alloc]init];
NSEntityDescription *dataEntityResultForm = [NSEntityDescription entityForName:@"Task" inManagedObjectContext:managedObjectContext];
[taskDataRequest setEntity:dataEntityResultForm];
//Note: Resolove problem happen data:fault by this properites
[taskDataRequest setReturnsObjectsAsFaults:NO];