• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSURL creation problem with colon: a partial workaround
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSURL creation problem with colon: a partial workaround


  • Subject: NSURL creation problem with colon: a partial workaround
  • From: Jérome Laurens <email@hidden>
  • Date: Thu, 18 Dec 2008 15:05:40 +0100

Hi list,

I have a relative path with colons "file:test", and I would like to create a NSURL relative to a given base URL "file://localhost/root/".
This does not work as expected.


Consider the simple URL creation method

NSURL * url1 = [NSURL fileURLWithPath:@"/root/file:test"];

The url is properly created and its absoluteURL reads

file://localhost/root/file:test/

If I use a base URL things go wrong

NSURL * url2 = [NSURL fileURLWithPath:@"/root/"];
NSURL * url3 = [NSURL URLWithString:@"file:test" relativeToURL:url2];

The absolute URL of url3 reads

file:test

which is not the expected value.
Apparently NSURL parses the string as if there were no base URL at all,
which produces a wrong value.
Fortunately, there is a warkaround by prepending "./" to the relative path.


NSURL * url4 = [NSURL URLWithString:@"./file:test" relativeToURL:url2];

The absolute URL of url4 reads

file://localhost/root/file:test

what is the expected value.

But the standardizedURL still reads the wrong value

file:test

So prepending "./" to the relative path is just a partial workaround.

Regards
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSURL creation problem with colon: a partial workaround
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: Validation of a Custom View NSToolbarItem
  • Next by Date: NSToolbar Error
  • Previous by thread: Override a UTI?
  • Next by thread: Re: NSURL creation problem with colon: a partial workaround
  • Index(es):
    • Date
    • Thread