Writing to a directory like Documents folder - Stack Overflow
黄舟
黄舟 2017-05-17 10:06:36
0
1
777

How to write the following directories into Documents?

The actual requirement is to load a website locally. I did an experiment myself. If I put it into the Documents folder, read the index.html file in it. Can be loaded normally. So I want to write the website files to the Documents file directory. But I can't figure out how to write a directory into it. I hope you can give me some ideas.

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
滿天的星座

If you want to create a folder directly in the project,
select Create folder references when dragging it into the project, and then you will see that the folder you dragged into the project is blue.
The structure in this folder will be saved, and you can directly use relative paths to obtain it when importing js and css.

Load your html:

//swift

let path = Bundle.main.path(forResource: "YourHTMLName", ofType: "html", inDirectory: "YourFolderName")
let url = NSURL.init(string: path!)
let request = NSURLRequest.init(url: url! as URL)
webView.loadRequest(request as URLRequest)

// OC
NSURL *html = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"YourHTMLName" ofType:@"html" inDirectory:@"YourFolderName"]];
NSURLRequest *request = [NSURLRequest requestWithURL:html];
[self.webView loadRequest:request];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template