I have a UIWebView that is being populated dynamically out of the values stored in NSUserDefaults and I would like to know the best way to allow a user to save the HTML document to the documents directory via a simple save button.
I load up the HTML file with the code below and my goal is to use the variable data stored in “pName1” as the document name if possible.
NSString *myHTML = [NSString stringWithFormat:@"<html><body><h1><center>My HTML content - %@</center></h1></body></html>",pName1];
[quickView loadHTMLString:myHTML baseURL:nil];
Any help would be greatly appreciated!
Thanks!
You’ve already got the data in a variable whose contents you display in a UIWebView. You can take that variable and write it straight to disk. The key is to take advantage of the
NSStringwriteToFile:atomically:encoding:error:method.Here’s a rough example:
See link: NSString.