I have an URL and need to extract a part of it.
The url is like this:
http://website.com/get.php?url=http://www.website2.com/index.html?articleID=123456
And I need to extract this part:
http://www.website2.com/index.html?articleID=123456
How would I do this in Objective-C?
First of all, create a NSURL. Then, use the query
method to get the query string part:
NSURL * url = [ NSURL URLWithString: @"... your url ..." ];
NSString * q = [ url query ];
Then you can use the NSString methods to isolate the needed part.
See the NSString
-rangeOfSubstring:
and -componentsSeparatedByString:
methods.
In this case, you could just split the string at the "=".