Reputation: 13
I am having one issue related extracting of string in iOS. I am getting NSURL value from WebView http://m.youtube.com/index?&desktop_uri=%2F, however i need to extract only http://m.youtube.com, i have tried many steps, however it didn't work, please help me regarding this issue.
Upvotes: 1
Views: 145
Reputation: 122458
Well looking at the NSURL
class reference, I can see that an NSURL
object has various properties that give you what you want:
http://m.youtube.com
| A | B |
A: Scheme
B: Host
So I think all you need to do is:
NSURL *url = ...;
NSString *scheme = url.scheme;
NSString *host = url.host;
NSLog(@"%@%@", scheme, host);
Job done. NEXT!
Upvotes: 1