0

毎回、ファイルを保存するときに 10 秒以上かかりますNSManagedObjectContext

これが私のコードです:

dispatch_queue_t requestQueue =  dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
        dispatch_async(requestQueue, ^{
        NSManagedObjectContext *manageContext = [[NSManagedObjectContext alloc]init];
        [manageContext setPersistentStoreCoordinator:[[OKCoreManager sharedManager] persistentStoreCoordinator]];
        Card *cardObject = (Card *)[NSEntityDescription insertNewObjectForEntityForName:@"Card" inManagedObjectContext:manageContext];
        cardObject.name = self.name;
        cardObject.title = self.title;
        cardObject.email = self.email;
        cardObject.address = self.address;
        cardObject.stacks = self.stackObject;
        cardObject.contact =self.contact;
        NSError *error;
        if (![[OKCoreManager sharedManager]saveManagedObjectContext:manageContext])
        {
             NSLog(@"Problem saving: %@", [error localizedDescription]);
             dispatch_sync(requestQueue, ^{
                     iCallBack(FALSE,selfObject);
             });
        }
        else
        {
             dispatch_sync(requestQueue, ^{
                      iCallBack(TRUE,selfObject);
             });
        }
        manageContext = nil;
});
4

1 に答える 1