ios - How can I overwrite or save an existing local HTML file that's edited in a UIWebView? -


the app uses uiwebview load local html files (which text) editing. need save whats been edited user local file. way think of doing that:

once text has been edited user, i've written save method takes current html in web view , saves html file (with same filename original) written documents directory. in theory should overwrite original. doesn't.

-(void)save{     nserror *err;     nsstring * docsdir = [nshomedirectory() stringbyappendingpathcomponent:@"documents"];     nsstring *oldfile = [self.webview.request.url lastpathcomponent];     //above line gets actual html file name that's in webview     nsstring * path = [docsdir stringbyappendingpathcomponent:oldfile];     //the following line gets html code in actual webview     nsstring *html = [self.webview stringbyevaluatingjavascriptfromstring:@"document.getelementsbytagname('html')[0].innerhtml"];      [html writetofile:path atomically:yes encoding:nsutf8stringencoding error:nil]; } 

no file seems written. doesn't overwrite original nor write new one.

perhaps shouldn't saving way, can't think of other methods of doing it.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -