问题
Imagine this is my URL
NSURL *theURL=[NSURL URLWithString:@"http://stackoverflow.com/questions/ask"];
How can i extract only:
http://stackoverflow.com
?
回答1:
How about [NSString stringWithFormat:@"%@://%@", [theURL scheme], [theUrl host]]
回答2:
Have you tried [theURL host]?
来源:https://stackoverflow.com/questions/8890475/how-to-extract-scheme-and-host-of-a-url-once