Re: NSURL relativePath problem
Re: NSURL relativePath problem
- Subject: Re: NSURL relativePath problem
- From: Ken Thomases <email@hidden>
- Date: Thu, 29 Aug 2013 13:16:06 -0500
On Aug 29, 2013, at 1:02 PM, Koen van der Drift wrote:
> I'm having some difficulties constructing a URL from a baseURL and a relativeURL when the relativeURL starts with a question mark:
>
> NSURL *baseURL = [NSURL URLWithString: @"http://www.test.com/test/"];
> NSString *relativeString = @"?query=test";
>
> NSURL *url = [NSURL URLWithString: relativeString relativeToURL: baseURL];
>
> This results in the following url:
>
> ?query=test -- http://www.test.com/test/
>
> While I want it to be:
>
> http://www.test.com/test/?query=test
>
>
> I can just generate the whole URL at once, but I was wondering why I get this behavior?
You are mistaking the description for the value. You must not use the description for anything other than logging/debugging/human consumption.
If you want the URL converted to absolute form, invoke -absoluteURL. If you need the URL as a string, invoke -absoluteString.
Regards,
Ken
_______________________________________________
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