Given a large string, what is the best way to create an array of all valid urls which are contained within the string?
This is best way to extract url link.
NSString *url_ = @"dkc://name.com:8080/123;param?id=123&pass=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]);
Output:
scheme: dkc
host: name.com
port: 8080
path: /12345
path components: ( "/", 123 ) parameterString: param
query: id=1&pass=2
fragment: fragment