Reputation: 1336
Is it possible to load a WebView with the text from a NSString? If I save the string content into a file and then use something like:
[[main_browser mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"file:///Volumes/AA/myfile.txt"]]];
It works, but how can I do it without writing the content into a file?
Upvotes: 0
Views: 1247
Reputation: 6991
Yeah you can load a NSString into a webview, just look at the following method:
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
You can also open files from the disk this way by creating a NSString object and then loading it into the webview. However using loadRequest might be better ( as it is doing the same thing, but then internally ).
If you want to write a NSString to a file you can:
[someStringObject writeToFile:_path_];
Did you actually take a look at the NSString class reference? It is pretty clear there.
Upvotes: 3