Wednesday, May 1, 2013

NSURL port example ios

port
Returns the port number of a URL conforming to RFC 1808.
- (NSNumber *)port
Return Value of [NSURL port]
The port number of the URL. If the receiver does not conform to RFC 1808, returns nil.
Example of [NSURL port]

NSString *url_ = @"foo://name.com:8080/12345;param?foo=1&baa=2#fragment";
NSURL *url = [NSURL URLWithString:url_];

NSLog(@"scheme: %@", [url scheme]); 
NSLog(@"host: %@", [url host]); 
NSLog(@"port: %@", [url port]);     
NSLog(@"path: %@", [url path]);     
NSLog(@"path components: %@", [url pathComponents]);        
NSLog(@"parameterString: %@", [url parameterString]);   
NSLog(@"query: %@", [url query]);       
NSLog(@"fragment: %@", [url fragment]);