Coredata performBlockAndWait executeFetchRequest获取空值

时间:2016-06-28 06:14:11

标签: ios objective-c core-data concurrency

下面是我的代码我试图从私有队列中的coredata实体获取包含但是作为回报我得到了空值。

-(NSArray *)fetch_agenda_for_financialdoc:(BOOL)isFinace
{
    __block NSArray *fetchRecords;
    NSManagedObjectContext *private = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
    [private setParentContext:self.managedObjectContext];
    [private performBlockAndWait:^{
        NSFetchRequest *request = [[NSFetchRequest alloc]init];
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"AgendaDetails" inManagedObjectContext:private];
        [request setEntity:entity];      
        NSError *error;
        fetchRecords = [private executeFetchRequest:request error:&error];
     }];
    for (AgendaDetails *obj in fetchRecords) {
        NSLog(@"%@",obj.agendaName);
    }
    return fetchRecords;
}

如果需要更多详细信息,我可以提前感谢您。

0 个答案:

没有答案