我建立了利用restkit對IOS的應用程序。我相信在緩存區有問題。我爲最初的啓動安裝了我的應用程序,以獲取大量數據並使用restkit將其映射到核心數據中。一切工作正常,數據以表格形式顯示。現在,如果我使應用程序進入後臺,然後再次單擊該應用程序以恢復我調用相同的方法來加載數據,但這個時候,我送版本號的服務器以已經改變只取回對象,添加或自上次拉後刪除。這一切都很好地映射,但是當我去顯示這些對象時,我會得到與第一次拉動相同的數據。我相信這可能是清除緩存問題,但我不知道。幫助是感激的。Restkit緩存發出的iOS更新保存屬性
RKObjectManager *的ObjectManager = [RKObjectManager objectManagerWithBaseURLString:@ 「http://link.com」]; objectManager.client.requestQueue.showsNetworkActivityIndicatorWhenBusy = YES; objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@ 「34453434.sqlite」]; RKManagedObjectMapping * cliffMapping = [RKManagedObjectMapping mappingForClass:[崖類] inManagedObjectStore:objectManager.objectStore];
cliffMapping.primaryKeyAttribute = @"cliffID";
cliffMapping.rootKeyPath = @"cliffs";
[cliffMapping mapKeyPath:@"name" toAttribute:@"name"];
[cliffMapping mapKeyPath:@"cliffId" toAttribute:@"cliffID"];
[cliffMapping mapKeyPath:@"description" toAttribute:@"cliffDescription"];
[cliffMapping mapKeyPath:@"notes" toAttribute:@"notes"];
[cliffMapping mapKeyPath:@"city" toAttribute:@"city"];
[cliffMapping mapKeyPath:@"intensity" toAttribute:@"intensity"];
[cliffMapping mapKeyPath:@"latitude" toAttribute:@"latitude"];
[cliffMapping mapKeyPath:@"height" toAttribute:@"height"];
[cliffMapping mapKeyPath:@"longitude" toAttribute:@"longitude"];
[cliffMapping mapKeyPath:@"zipcode" toAttribute:@"zipcode"];
[objectManager.mappingProvider setMapping:cliffMapping forKeyPath:@"cliffs"];
[objectManager.mappingProvider addObjectMapping:cliffMapping];
RKManagedObjectMapping* stateMapping = [RKManagedObjectMapping mappingForClass:[State class] inManagedObjectStore:objectManager.objectStore];
stateMapping.rootKeyPath = @"States";
stateMapping.primaryKeyAttribute = @"stateID";
[stateMapping mapKeyPath:@"stateId" toAttribute:@"stateID"];
[stateMapping mapKeyPath:@"name" toAttribute:@"name"];
[stateMapping mapKeyPath:@"version" toAttribute:@"sversion"];
[stateMapping mapKeyPath:@"cliffAmount" toAttribute:@"cliffAmount"];
[stateMapping mapRelationship:@"cliffs" withMapping:cliffMapping];
[objectManager.mappingProvider setMapping:stateMapping forKeyPath:@"States"];
[objectManager.mappingProvider addObjectMapping:stateMapping];
[objectManager loadObjectsAtResourcePath:@"/Application/getEverything" usingBlock:^(RKObjectLoader *loader){
loader.serializationMIMEType = RKMIMETypeJSON;
loader.resourcePath = @"/Application/getEverything";
loader.method = RKRequestMethodPOST;
loader.delegate = self;
loader.objectMapping = stateMapping;
}];