How does
baseURL
work?
Here are some helpful examples from the AFNetworking documentation:
NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
[NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
[NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
[NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
[NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
Basically, any files in your HTML will be assumed to be in the location specified in the Base URL. If the HTML specifies files beginning with /
, the domain name will stay the same but the path of the Base URL will be ignored. If the HTML specifies files beginning with http(s)://
, the entire Base URL will be ignored.
In your example, the URL would resolve to https://myserveraddress/Data/iPhone/my.css
.
How can I output the
infoWebView
source to NSString?
A simple solution is:
NSString *html = [InfoWebview stringByEvaluatingJavaScriptFromString:
@"document.body.innerHTML"];
More info and discussion on this topic is available on Stack Overflow here.