RestKit 0.20.2 では、次の例でうまくいきます。ファイル RKTestFactory.m の RestKit/Testing コンポーネントにあるコードに基づいており、私のプロジェクトでうまく機能しています。
また、RestKit が CoreData スタックを管理している場合 (これが私のセットアップ方法です)、RestKit セットアップで NSManagedObjectContext を使用している NSFetchedResultsController を削除することを忘れないでください。
- (void)tearDownRestKit
{
// Cancel any network operations and clear the cache
[[RKObjectManager sharedManager].operationQueue cancelAllOperations];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
// Cancel any object mapping in the response mapping queue
[[RKObjectRequestOperation responseMappingQueue] cancelAllOperations];
// Ensure the existing defaultStore is shut down
[[NSNotificationCenter defaultCenter] removeObserver:[RKManagedObjectStore defaultStore]];
// Not be needed if not using indexer
if ([[RKManagedObjectStore defaultStore] respondsToSelector:@selector(stopIndexingPersistentStoreManagedObjectContext)]) {
// Search component is optional
[[RKManagedObjectStore defaultStore] performSelector:@selector(stopIndexingPersistentStoreManagedObjectContext)];
if ([[RKManagedObjectStore defaultStore] respondsToSelector:@selector(searchIndexer)]) {
id searchIndexer = [[RKManagedObjectStore defaultStore] valueForKey:@"searchIndexer"];
[searchIndexer performSelector:@selector(cancelAllIndexingOperations)];
}
}
[RKObjectManager setSharedManager:nil];
[RKManagedObjectStore setDefaultStore:nil];
}