Reachability *r = [Reachability reachabilityWithHostName:@"www.google.com"];
This line works fine on device, but on simulator i get crash :
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Reachability reachabilityWithHostName:]: unrecognized selector sent to class
Does anyone know why ?
I had almost the same problem, except that linker did not link Reachability after I added it via pod.
internetReachable = [Reachability reachabilityWithHostName:@"www.google.com"];
In this line compiler was giving error 'No known class method for selector reachabilityWithHostName:'.
I tried to readd reachability, tried to clean project, nothing helped. Then I just tried to rewrite this line and it compiled!
internetReachable = [Reachability reachabilityWithHostname:@"www.google.com"];
And now I understand why it worked. Because my old code was taken from another project with other version of Reachability and selector was with 'HostName' but new one is with 'Hostname'.
Before rewriting I was checking if Reachability has this method and it seemed to me that it has and I couldn't understand the problem. It turned out that I didn't notice this small change in one letter!
solved, I was upgrading Reachability, I searched the web and I found that somewhere someone had this before and just delete systemconfiguration framework and re add it, clean the project and then build again and it will work on both simulator and device perfectly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With