I have saved an html page using the following line of code :
NSURL *yoyoyo = [[NSURL alloc] initWithString:@"www.google.com"];
NSData *data = [[NSData alloc] initWithContentsOfURL:yoyoyo];
NSString *html = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *documentsDirectory = @"/Users/xxxx/Library/Application Support/iPhone Simulator/5.1/Applications/";
NSLog(@"%@", documentsDirectory);
NSString *htmlFilePath = [documentsDirectory stringByAppendingPathComponent:@"file.html"];
[html writeToFile:htmlFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
The file named as gets saved as “file.html” folder in the path mentioned i.e. documentsDirectory. Is there a way that I can open this file in safari or webView of my application ?? Thanks and Regards.
to load it in your web view, do the following
You also have an issue in getting
documentDirInstead of
use
Save the file again and try to load using the above code