ios - UIWebView Copy Cache Data For Offline View -
i want copy cache data database(sqlite/coredata) can view while offline (without internet) " reading list in safari ". read code @ xcode uiwebview download , save html file , show following:-
- (void)viewdidload { nsurl *url = [nsurl urlwithstring:@"http://livedemo00.template-help.com/wt_37587/index.html"]; //[webview loadrequest:requrl]; // determile cache file path nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *filepath = [nsstring stringwithformat:@"%@/%@", [paths objectatindex:0],@"index.html"]; // download , write file nsdata *urldata = [nsdata datawithcontentsofurl:url]; [urldata writetofile:filepath atomically:yes]; // load file in uiwebview [webview loadrequest:[nsurlrequest requestwithurl:[nsurl fileurlwithpath:filepath]]]; [super viewdidload]; }
but problem code not show images while offline .
so thought saving data cache database option.can share sample code copy website content along images database.
thank in advance
you may used asiwebpagerequest , example given here
or
if reachability got connectivity
nscachedurlresponse* response = [[nsurlcache sharedurlcache] cachedresponseforrequest:[webview request]]; nsdata* data = [response data];
store data in locally , use whenever got reachability offline.
Comments
Post a Comment