• 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
Re: Create a NSURL as a way to validate urls - not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Juanjo Conti <email@hidden>
  • Date: Tue, 03 Mar 2015 11:42:02 -0300

Ok, first of all thanks all for the replies.

I'm trying to solve it this an util class method:

import Cocoa

class Utils: NSObject {

    class func isValidUrl(url: NSURL?) {
       var lower = url?.scheme?.lowercaseString
        return lower == "http" || lower == "https"
  }
}
Sadly I'm getting and error in the return line that I can't interprete:
Cannot invoke == with argument list of type `($T4, $T8)`

What I'm doing wrong?

Thanks,

On Tue, Mar 3, 2015 at 6:19 AM, Mike Abdullah <email@hidden> wrote:

>
> On 3 Mar 2015, at 01:57, Jens Alfke <email@hidden> wrote:
>
>
> On Mar 2, 2015, at 3:55 PM, Juanjo Conti <email@hidden> 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.
>
>


--

Juanjo Conti <jjconti <http://goog_2023646312>@carouselapps.com
<email@hidden>>

Software Engineer - Carousel Apps <https://carouselapps.com>

--
Carousel Apps Limited, registered in England & Wales with registered number
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel
App Ltd or any of its subsidiary, holding or affiliated companies or
entities (together "Watu") is confidential and may be privileged or
otherwise protected. If you receive it in error please inform us and then
delete it from your system. You should not copy it or disclose its contents
to anyone. Messages sent to and from Watu may be monitored to ensure
compliance with our internal policies and to protect our business. Emails
are not secure and cannot be guaranteed to be error free. Anyone who
communicates with us by email is taken to accept these risks.
_______________________________________________

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: Create a NSURL as a way to validate urls - not working
      • From: Marco S Hyman <email@hidden>
    • Re: Create a NSURL as a way to validate urls - not working
      • From: Roland King <email@hidden>
References: 
 >Create a NSURL as a way to validate urls - not working (From: Juanjo Conti <email@hidden>)
 >Re: Create a NSURL as a way to validate urls - not working (From: Mike Abdullah <email@hidden>)
 >Re: Create a NSURL as a way to validate urls - not working (From: Juanjo Conti <email@hidden>)
 >Re: Create a NSURL as a way to validate urls - not working (From: Jens Alfke <email@hidden>)
 >Re: Create a NSURL as a way to validate urls - not working (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Muting keyboard of the application
  • Next by Date: Re: Create a NSURL as a way to validate urls - not working
  • Previous by thread: Re: Create a NSURL as a way to validate urls - not working
  • Next by thread: Re: Create a NSURL as a way to validate urls - not working
  • Index(es):
    • Date
    • Thread