Since iOS 7 , you can use NSURLComponents , which is very easy to use. Take a look at these examples:
Example 1
NSString *urlString = @"https://mail.google.com/mail/u/0/?shva=1#inbox"; NSURLComponents *components = [[NSURLComponents alloc] initWithString:urlString]; NSLog(@"%@ - %@ - %@ - %@", components.scheme, components.host, components.query, components.fragment);
Example 2
NSString *urlString = @"https://mail.google.com/mail/u/0/?shva=1#inbox"; NSURLComponents *components = [[NSURLComponents alloc] initWithString:urlString]; if (components) {
Example 3
NSURLComponents *components = [NSURLComponents new]; [components setScheme:@"https"]; [components setHost:@"mail.google.com"]; [components setQuery:@"shva=1"]; [components setFragment:@"inbox"]; [components setPath:@"/mail/u/0/"]; [self.webview loadRequest:[[NSURLRequest alloc] initWithURL:[components URL]]];
But you can do many other things with NSURLComponents, take a look at the NSURLComponents class link to Apple documentation or this link: http://nshipster.com/nsurl/
Salmo Feb 26 '14 at 18:18 2014-02-26 18:18
source share