Dans RestKit 0.20.2 l'exemple suivant fait l'affaire. Son code off basé dans le composant RestKit/Testing dans le fichier RKTestFactory.m et a fonctionné très bien dans mon projet.
En outre, si RestKit gère votre pile CoreData, ce qui est la mienne, n'oubliez pas de supprimer tout NSFetchedResultsController qui utilise NSManagedObjectContext dans votre configuration RestKit.
- (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];
}
à partir de RestKit 0.20 vous aurez besoin d'utiliser '[[RKManagedObjectStore defaultStore] resetPersistentStores: nil];' –
A travaillé pour moi en utilisant RestKit 0.20 http://stackoverflow.com/a/18425303/1318202 –
Salut @ blake-watts comment faire cela dans la version 0.20 –