0

I have an NSTextView control that could potentially have links in it. How do I get the full url of the link?

Here is what I have so far

-(BOOL)textView:(NSTextView *)aTextView clickedOnLink:(id)aLink atIndex:(NSUInteger)charIndex 
 {
     NSURL *htmlURL = [NSURL fileURLWithPathComponents:[aLink pathComponents]];
 }

This gives me a URL that begins with file://localhost ... How do I get rid of that portion of the URL?

akjoshi
  • 15,374
  • 13
  • 103
  • 121
  • 1
    it may be similar to this [question](http://stackoverflow.com/questions/3692947/get-parts-of-a-nsurl-in-objective-c-for-iphone) – BabyPanda Nov 16 '12 at 07:18

1 Answers1

0
NSURL* url = [NSURL URLWithString:@"http://localhost/myweb/index.html"];
NSString* reducedUrl = [NSString stringWithFormat:
    @"%@://%@",
    url.scheme,
    [url.pathComponents objectAtIndex:1]];
Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40