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

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

matplotlib - PYTHON: Annotate boxes disapear dependant on range -