Re: Create a NSURL as a way to validate urls - not working
Re: Create a NSURL as a way to validate urls - not working
- Subject: Re: Create a NSURL as a way to validate urls - not working
- From: Mike Abdullah <email@hidden>
- Date: Mon, 02 Mar 2015 23:46:56 +0100
> On 2 Mar 2015, at 23:22, Juanjo Conti <email@hidden> wrote:
>
> According the docs (
> https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/)
> NSURL(string: aString) will return nil if aString is malformed.
>
> But I've tried this in the a playground and no nil is returned:
>
> NSURL(string: "")!
> NSURL(string: "ssss")!
>
> Why is this? are the docs wrong?
Go read the specs NSURL references. An empty string and “ssss” are both valid by its definition.
Pretty much all NSURL is looking for is you’re not using any unsupported characters, or mis-using reserved characters. Anything more, and you’ve got to test the resulting URL yourself. Perhaps you can elaborate what you consider to be a valid URL in your case.
_______________________________________________
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