> 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?

You didn't specify the return type of the function.
lower is an optional and may be nul.
Why is it a class function?

Try it this way using a global function

func isValidUrl(url: NSURL?) -> Bool {
    if let lower = url?.scheme?.lowercaseString {
        return lower == "http" || lower == "https"
    }
    return false
}

let foo = NSURL(string: "some/string")
let bar = NSURL(string: "http://some/string";)
isValidUrl(foo)         // false
isValidUrl(bar)         // true


I'd also rename the the function to hasHTTPScheme or something similar.
_______________________________________________

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

Reply via email to