Ответ 1
Вы хотите вызвать [[RKClient sharedClient].requestCache invalidateAll];
, чтобы очистить кеш. Вы можете просмотреть документы API.
Я использую RestKit для вызовов webservice, кеширования и etags. Я реализовал свою собственную модель coredata и managedObjects
Как только пользователь выйдет, мне нужно очистить все данные в базе данных. Я смог успешно удалить файл sqlite и воссоздать его, но я не могу найти способ очистить все данные RestKit catching и etag. Как я могу полностью стереть все данные, хранящиеся в RestKit?
Вы хотите вызвать [[RKClient sharedClient].requestCache invalidateAll];
, чтобы очистить кеш. Вы можете просмотреть документы API.
Используйте следующий метод из класса RKManagedObjectStore.
- (void)deletePersistantStoreUsingSeedDatabaseName:(NSString *)seedFile
В Restkit 0.20 попробуйте следующее:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
работал у меня =)
В RestKit 0.20.2 следующий пример делает трюк. Его основанный на коде код найденный в компоненте RestKit/Testing в файле RKTestFactory.m и отлично поработал в моем проекте.
Кроме того, если RestKit управляет стеком CoreData, который настроен моим, не забудьте удалить любой NSFetchedResultsController, которые используют NSManagedObjectContext в настройке 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];
}