Re: -[NSURL path] returning empty string for relative file URL
Re: -[NSURL path] returning empty string for relative file URL
- Subject: Re: -[NSURL path] returning empty string for relative file URL
- From: Glen Simmons <email@hidden>
- Date: Fri, 11 Nov 2005 08:45:27 -0600
On Nov 11, 2005, at 7:51 AM, Niko Matsakis wrote:
Hmm. The problem there is that if I don't put in a scheme, then
the NSURL I get back when the link is clicked in the NSTextView is
that applewebdata thing, which is a bit ... unwieldy.
After sending my message I feared you would encounter this
problem. I'm not familiar with the specifics of your situation,
but I think your only hope is to obtain the relevant "Base URL" and
construct a URL like so:
NSURL *url = [NSURL URLWithString:@"relative/path"
relativeToURL:baseURL];
If you do not know the base URL at the time, then you cannot store
an NSURL. To my knowledge, NSURL instances are always absolute.
You'll have to settle for storing the string and converting it to a
URL when the base URL is known.
Well, I'm not creating the NSURL in this case, the NSTextView is. I'm
shoving some XHTML into the NSTextView and it's interpreting anchors
as clickable links. When clicked, my textView:clickedOnLink:atIndex:
method gets called with the NSURL in question. The original XHTML had
this:
<a href="foo.bar"><span>Link to foo.bar</span></a>
But if I shove it into the NSTextView like that, the NSURL I get back
looks like this:
applewebdata://108AB768-64CD-41CF-94FA-C4558EBA0B1E/foo.bar
which is a bit difficult to deal with.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden