Wednesday, May 1, 2013

NSURL query example ios

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

Example of [NSURL query]
NSString *url_ = @"foo://;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]);