> On 3 Mar 2015, at 01:57, Jens Alfke <j...@mooseyard.com> wrote: > > >> On Mar 2, 2015, at 3:55 PM, Juanjo Conti <jjco...@carouselapps.com >> <mailto:jjco...@carouselapps.com>> wrote: >> >> Ok, I wanted to validate that the url is an absolute one. Is there >> something in Swift standard lib to do this? > > I typically check whether url.scheme is a non-nil, non-empty string. You may > also want to check the scheme if you need to restrict input to HTTP URLs, for > instance. (For example, “a:b” is a perfectly valid absolute URL, but probably > not one your app will find useful.) Keep in mind that URL schemes are > case-insensitive, so “HTTP:” means the same as “http:”. > > Also, this has nothing to do with the Swift library. NSURL is part of the > Foundation framework, so this is independent of whether you’re using Swift or > Objective-C.
I’d say this is pretty good advice. The NSURL docs also used to mention an alternative, that you could test the -resourceSpecifier to see if it began with // as a pretty good test, but that’s no longer mentioned, which is intriguing. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com