Reputation: 267
I'm using CocoaHTTPServer
, and I'm able to start the server. In my resources folder, I added a file called "index.html", and here is something that made me confused.
I can get the path of the index file by
[mainbundle pathForResource:@"index" ofType:@"html"]
but it gave me the path as
/Users/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/
.
Is there any way to make the path become a web-url like
http://127.0.0.1:56000/user/library/.../index.html"
to load it on an
UIWebView.
Is there any way for me to achieve it?? Thanks in advance.
Upvotes: 0
Views: 266
Reputation: 9865
You can load a resource into a UIWebView
like this
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"]];
[webview loadRequest:[NSURLRequest requestWithURL:url]];
For catching the requests of a UIWebView
please check UIWebViewDelegate
protocol here. You can play around with following method for example webView:shouldStartLoadWithRequest:navigationType:
Upvotes: 1