के साथ काम नहीं कर रहा है, मैं अपने ऐप में AFNetworking का उपयोग कर रहा हूं और उपलब्ध होने पर कैश किए गए डेटा का उपयोग करके इसे ऑफ़लाइन मोड में काम करने का प्रयास करता हूं।AFNetworking (AFHttpClient) ऑफ़लाइन मोड NSURLRequestReturnCacheDataDontLoad नीति
मुझे उम्मीद है कि मैं अनुरोध कैश नीति को NSURLRequestReturnCacheDataDontLoad, getPath: पैरामीटर: सफलता: विफलता: ऑफ़लाइन होने पर कैश किए गए डेटा के साथ सफलता प्राप्त करूंगा। हालांकि, भले ही कैश (मैं चेक द्वारा कोड के साथ कैश सत्यापित) में डेटा कर रहे हैं, getPath बस हवाई जहाज मोड में असफल हो जायेगी।
AFNetworking github में एक धागा था: https://github.com/AFNetworking/AFNetworking/issues/378 लेकिन ऐसा लगता है कि इस मुद्दे को बिल्कुल संबोधित नहीं किया गया है। AFNetworking के लेखक बस Apple's document को इंगित, और यह कहा:
NSURLRequestReturnCacheDataDontLoad Specifies that the existing cache data should be used to satisfy a request, regardless of its age or expiration date. If there is no existing data in the cache corresponding to a URL load request, no attempt is made to load the data from the originating source, and the load is considered to have failed. This constant specifies a behavior that is similar to an “offline” mode.
के रूप में एप्पल ने कहा, NSURLRequestReturnCacheDataDontLoad वास्तव में ऑफ़लाइन मोड के लिए बनाया गया है।
मैं आईओएस 6 में परीक्षण कर रहा हूं, मैंने NSRLCache और SDURLCache दोनों के साथ परीक्षण किया है, सभी का एक ही परिणाम है।
अनुरोध विफल, त्रुटि संदेश:
2012-12-22 03:11:18.988 Testapp[43692:907] error: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x211b87c0 {NSErrorFailingURLStringKey=http://Testapp.com/api/v1/photo/latest/, NSErrorFailingURLKey=http://Testapp.com/api/v1/photo/latest/, NSLocalizedDescription=The Internet connection appears to be offline., NSUnderlyingError=0x211b9720 "The Internet connection appears to be offline."}