收到对象restkit v0.20.3后主线程被阻塞

一旦我从服务器获取数据,它将使用Entity mapping保存在持久性存储中。

然后我manually delete这些对象。

现在,当我试图再次拉相同的数据时,我得到的错误说,映射HTTP响应无目标对象… RKObjectmapperoperation失败。

主线程被阻塞的可能是其中的pipe理上下文在删除后没有对象图。 我不知道如何解决这个错误,我试图重置持久性存储。

UPDATE

 - (void)saveThreadedContext { NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; [defaultCenter addObserver:self selector:@selector(mergeThreadedContextChangesIntoMainContext:) name:NSManagedObjectContextDidSaveNotification object:self.threadedContext]; if ([[self threadedContext] hasChanges]) { NSError *error; BOOL contextDidSave = [[self threadedContext] save:&error]; if (!contextDidSave) { // If the context failed to save, log out as many details as possible. NSLog(@"Failed to save to data store: %@", [error localizedDescription]); NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey]; if (detailedErrors != nil && [detailedErrors count] > 0) { for (NSError* detailedError in detailedErrors) { NSLog(@" DetailedError: %@", [detailedError userInfo]); } } else { NSLog(@" %@", [error userInfo]); } } } [defaultCenter removeObserver:self name:NSManagedObjectContextDidSaveNotification object:[self threadedContext]]; self.threadedContext = nil; } #pragma mark - #pragma mark PrivateMethods - (void)mergeThreadedContextChangesIntoMainContext:(NSNotification *)notification { NSLog(@"%@:%@ merging changes", self, NSStringFromSelector(_cmd)); NSManagedObjectContext * context = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).managedObjectContext; [context performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:) withObject:notification waitUntilDone:YES]; } 

我使用[self saveThreadedContext]; 删除对象后保存并合并线程上下文。

 [context performSelectorOnMainThread:@selector(mergeChangesFromContextDidSaveNotification:) withObject:notification waitUntilDone:YES]; 

在restkit尝试合并上下文时导致该块的contextlocking。 想知道在创build用于删除对象的threadContext的时候使用什么types的并发。 我尝试了waitunitdone:NO和块不再出现..需要解释为什么