#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSURL *url = [NSURL URLWithString:@"http://www.testurl.com:8080/subpath/subsubpath?uid=123&gid=456"]; NSLog(@"scheme = %@",[url scheme]); // http NSLog(@"host = %@",[url host]); // www.testurl.com NSLog(@"port = %@",[url port]); // 8080 NSLog(@"path = %@",[url path]); // /subpath/subsubpath NSLog(@"lastPathComponent = %@",[url lastPathComponent]); // subsubpath NSLog(@"query = %@",[url query]); // uid=123&gid=456 NSLog(@"absoluteString = %@", [url absoluteString]); / / http://www.testurl.com:8080/subpath/subsubpath?uid=123&gid=45 / / relative path search NSLog (@ "relativePath = % @", [url relativePath]); // /subpath/subsubpath } @endCopy the code