1

Actually Iam checking for internet connection in my code and i get a weird error "Could not find an overload for '==' that accepts the supplied arguments"

Here is my code snippet,

override func viewDidLoad() {
        super.viewDidLoad()

        checkkNetworkStatus()

        let requestURL = NSURL(string: "http://example")

        let request = NSURLRequest(URL: requestURL!)

        webView.loadRequest(request)

    }


func checkkNetworkStatus(){

        let networkChecking : Reachability = Reachability.reachabilityForInternetConnection()

        networkChecking.startNotifier()

        var status : NetworkStatus = networkChecking.currentReachabilityStatus()

        if (status == NotReachable)   ***//error***
        {
            // statement
        }

}
Legolas
  • 805
  • 1
  • 11
  • 24

2 Answers2

2

Your error lies in your if-statement:

if status == NotReachable

You have to rewrite it like this:

if status == .NotReachable

or this:

if status == NetworkStatus.NotReachable

status is an Enum value and you access the different properties of Enums in one of the two ways I wrote.

If you want to know more about enum, you should check the docs.

ezcoding
  • 2,974
  • 3
  • 23
  • 32
0

You can do if (status == .NotReachable) or if (status == NetworkStatus.NotReachable).

Arda Keskiner
  • 772
  • 7
  • 23