Search code examples
iosswiftreachability

cannot invoke initializer for type 'Reachability' with no argument


I want to use the ReachabilitySwift class in my application. I added the dependency in my podFile and I get the code from github.

I got this error:

cannot invoke initializer for type 'Reachability' with no argument" on this line

My code:

let reachability = Reachability()!

Can anyone help me please?


Solution

  • Thanks to the answer in this link and also this one, my project is running perfectly and my problem is solved.

    By doing this: var reachability: Reachability! I can check the network reachability without using any host for the check.