Re: My eyes are failing me.
Re: My eyes are failing me.
- Subject: Re: My eyes are failing me.
- From: Ken Thomases <email@hidden>
- Date: Fri, 22 Feb 2019 10:45:08 -0600
On Feb 22, 2019, at 10:39 AM, Alex Zavatone <email@hidden> wrote:
>
> I was adding some basic networking code to a simple case test and decided to
> try out NSURL URLWithString: relativeToURL:
>
> As can be seen in the output below, it attempts to be doing the opposite of
> what is expected. All I am trying to do is append a string to an NSURL and
> get back an NSURL.
>
> Am I making some monumentally obvious mistake in the code below? Because I
> can’t see it.
>
> FYI, Xcode 10.1, iOS 12.1
>
>
> self.loginURL = [NSURL URLWithString:@"/login"
> relativeToURL:self.sharedData.webServicesURL]; // // WHY does this not work?
> It does "/login -- https://qa-home.mrcooper.com/api"
In what way, other than its debug description, does it "not work"? Have you
tried actually using it?
> (lldb) po self.sharedData.webServicesURL
> https://qa-home.mrcooper.com/api
>
> (lldb) po [NSURL URLWithString:@"/login"
> relativeToURL:self.sharedData.webServicesURL]
> /login -- https://qa-home.mrcooper.com/api
>
> (lldb) po self.sharedData.webServicesURL.absoluteString
> https://qa-home.mrcooper.com/api <https://qa-home.mrcooper.com/api>
Remember that "po" just asks the object to describe itself. NSURL objects
which were constructed relative to another URL describe themselves that way,
with the relative part and then the relative-to URL. That self-description
doesn't affect how it works. What you didn't do was:
po [[NSURL URLWithString:@"/login"
relativeToURL:self.sharedData.webServicesURL] absoluteString]
That would have shown the URL you expected.
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