Objective-C
Objective-C
Parse a URL into its Component Parts
See more HTTP Examples
Demonstrates how to parse a URL into it's component parts.Chilkat Objective-C Downloads
#import <CkoUrl.h>
#import <NSString.h>
BOOL success = NO;
CkoUrl *url = [[CkoUrl alloc] init];
NSString *urlStr = @"https://www.amazon.com/Anarchy-State-Utopia-Robert-Nozick/dp/0465051006/ref=sr_1_1?s=books&ie=UTF8&qid=1430344305&sr=1-1&keywords=nozick#frag123";
success = [url ParseUrl: urlStr];
// Assume success..
NSLog(@"%@%@",@"URL: ",urlStr);
NSLog(@"%@%@",@"Host: ",url.Host);
NSLog(@"%@%d",@"Port: ",[url.Port intValue]);
NSLog(@"%@%@",@"HostType: ",url.HostType);
NSLog(@"%@%d",@"Ssl: ",url.Ssl);
NSLog(@"%@%@",@"Path: ",url.Path);
NSLog(@"%@%@",@"Query: ",url.Query);
NSLog(@"%@%@",@"Frag: ",url.Frag);
NSLog(@"%@",@"----");
urlStr = @"http://matt:secret@www.chilkatsoft.com:8080/somepath.asp?test=123&size=2";
success = [url ParseUrl: urlStr];
// Assume success..
NSLog(@"%@%@",@"URL: ",urlStr);
NSLog(@"%@%@",@"Host: ",url.Host);
NSLog(@"%@%d",@"Port: ",[url.Port intValue]);
NSLog(@"%@%@",@"HostType: ",url.HostType);
NSLog(@"%@%d",@"Ssl: ",url.Ssl);
NSLog(@"%@%@",@"Login: ",url.Login);
NSLog(@"%@%@",@"Password: ",url.Password);
NSLog(@"%@%@",@"Path: ",url.Path);
NSLog(@"%@%@",@"Query: ",url.Query);
NSLog(@"%@%@",@"Frag: ",url.Frag);