URL截取问题

来源:互联网 发布:天刀涂山红红捏脸数据 编辑:程序博客网 时间:2024/05/16 10:12

URL截取问题

下面的代码来自AFNetworing的注释

NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];[NSURL URLWithString:@"foo" relativeToURL:baseURL]; 打印:http://example.com/v1/fooNSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];[NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL];          打印:http://example.com/v1/foo?bar=bazNSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];[NSURL URLWithString:@"/foo" relativeToURL:baseURL];                 打印:http://example.com/fooNSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];[NSURL URLWithString:@"foo/" relativeToURL:baseURL];                 打印:http://example.com/v1/fooNSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];[NSURL URLWithString:@"/foo/" relativeToURL:baseURL];                打印:http://example.com/foo/NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];[NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; 打印// http://example2.com/
0 0
原创粉丝点击