2
我使用以下方法從服務器使用RestKit(0.10.0)和後端核心數據加載編輯對象。作爲同步過程的一部分的方法在應用程序進入前臺時被調用。RestKit - 僅在第二次調用時纔將緩存保存到核心數據
[syncObjectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"?config=accounts&since=%@", lastSync] usingBlock:^(RKObjectLoader *loader) {
[loader.mappingProvider setObjectMapping:companyMappingSync forKeyPath:@"data"];
loader.backgroundPolicy = RKRequestBackgroundPolicyContinue;
loader.delegate = self;
}];
響應加載正常,緩存似乎也被發現。
2012-04-11 15:58:32.147 mobileCRM[3575:707] T restkit.support:RKCache.m:82 Found cachePath '/var/mobile/Applications/C5E4BF4F-4CB0-4F4C-AC11-FC1E17AE4AF2/Library/Caches/RKClientRequestCache-www.URLTOSERVER.de/PermanentStore/37abc4aff62918578288d10530e6bcd6' for PermanentStore/37abc4aff62918578288d10530e6bcd6
2012-04-11 15:58:32.152 mobileCRM[3575:707] T restkit.support:RKCache.m:119 Wrote cached data to path '/var/mobile/Applications/C5E4BF4F-4CB0-4F4C-AC11-FC1E17AE4AF2/Library/Caches/RKClientRequestCache-www.URLTOSERVER.de/PermanentStore/37abc4aff62918578288d10530e6bcd6'
2012-04-11 15:58:32.158 mobileCRM[3575:707] T restkit.support:RKCache.m:100 Writing dictionary to cache key: 'PermanentStore/37abc4aff62918578288d10530e6bcd6.headers'
2012-04-11 15:58:32.159 mobileCRM[3575:707] T restkit.support:RKCache.m:82 Found cachePath '/var/mobile/Applications/C5E4BF4F-4CB0-4F4C-AC11-FC1E17AE4AF2/Library/Caches/RKClientRequestCache-www.URLTOSERVER.de/PermanentStore/37abc4aff62918578288d10530e6bcd6.headers' for PermanentStore/37abc4aff62918578288d10530e6bcd6.headers
2012-04-11 15:58:32.166 mobileCRM[3575:707] T restkit.support:RKCache.m:103 Wrote cached dictionary to cacheKey 'PermanentStore/37abc4aff62918578288d10530e6bcd6.headers'
當測試屬性「街道」的變化時,變化也被很好地映射。
2012-04-11 15:58:33.013 mobileCRM[3575:1a03] T restkit.object_mapping:RKObjectMappingOperation.m:332 Mapped attribute value from keyPath 'street' to 'street'. Value: Musterweg 55
完成操作後,我調用一個新的fetchRequest並重新加載所屬表視圖。
問題
不知何故所述第一呼叫之後的改變的對象不被保存在後端(即使核心數據示出了COMMIT消息)。
2012-04-11 16:05:44.235 mobileCRM[3603:351f] I restkit.core_data:RKInMemoryEntityCache.m:131 Caching all 2861 Company objectsIDs to thread local storage
2012-04-11 16:05:44.354 mobileCRM[3603:351f] CoreData: sql: BEGIN EXCLUSIVE
2012-04-11 16:05:44.357 mobileCRM[3603:351f] CoreData: sql: UPDATE ZCOMPANY SET ZSTREET = ?, Z_OPT = ? WHERE Z_PK = ? AND Z_OPT = ?
2012-04-11 16:05:44.361 mobileCRM[3603:351f] CoreData: sql: COMMIT
但是,當我第二次打開應用程序再次調用該方法時,刷新的數據如預期顯示。所以我很努力讓這個方法在第一次通話中工作。
感謝您的想法!
根據問題/答案計劃,您應將解決方案作爲答案發布並接受它。這有助於其他用戶看到這是一個解決的問題並找到答案。 – Kai 2012-04-12 10:23:15
下次會記住它,謝謝! – flashfabrixx 2012-04-12 13:39:02