4

I'm using the Reachability sample code provided by Apple to check the network connectivity and get notified of changes (Reachability Sample code).

I had a look at some crash locks of my app. It seems that some crashes are due to the Reachability/SystemConfiguration Reachablity API stuff (see below). SCNetworkReachabilityGetFlags is only used in the Reachability class provided by Apple. Or am I misinterpreting the crash log?

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib              0x00000e70 mach_msg_trap + 20
1   libSystem.B.dylib              0x00003354 mach_msg + 60
2   SystemConfiguration            0x0001f480 configopen + 168
3   SystemConfiguration            0x00004d08 SCDynamicStoreCreateWithOptions + 272
4   SystemConfiguration            0x00004e54 SCDynamicStoreCreate + 24
5   SystemConfiguration            0x00015244 updateReachabilityStoreInfo + 152
6   SystemConfiguration            0x00016f04 updateCommCenterStatus + 32
7   SystemConfiguration            0x00017678 checkAddress + 1368
8   SystemConfiguration            0x0001a260 __SCNetworkReachabilityGetFlags + 1992
9   SystemConfiguration            0x0001b00c rlsPerform + 132
10  CoreFoundation                 0x00058266 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
11  CoreFoundation                 0x00028692 __CFRunLoopDoSources0 + 214
12  CoreFoundation                 0x00027f62 __CFRunLoopRun + 258
13  CoreFoundation                 0x00027d74 CFRunLoopRunSpecific + 220
14  CoreFoundation                 0x00027c82 CFRunLoopRunInMode + 54
15  GraphicsServices               0x00004e84 GSEventRunModal + 188
16  UIKit                          0x00004f8c -[UIApplication _run] + 564
17  UIKit                          0x000024cc UIApplicationMain + 964
18  MyApp                          0x0000f80c main (main.m:21)
19  MyApp                          0x0000f77c start + 44
Marc
  • 233
  • 4
  • 6

4 Answers4

3

I found it better to just try to open network connection. Then if it fails, set a flag to try latter and avoid "reachability". Even if "reachability" passes at startup it can fade in and out at anytime.

nolimitsdude
  • 631
  • 5
  • 9
  • I agree with this, but you can use reachability to "help out"; for example, by letting the user know that they're probably not connected to the internet when a request fails. – Jesse Rusak Dec 10 '12 at 02:23
0

Use it in the first view controller. It's easy to get in trouble when using it in modal view or other derivative views.

Jackie Lee
  • 239
  • 3
  • 3
0

Reachability is one of the worst of Apple's sample code examples.

Although it's good at notifying of network connections, it's rather poor [read: hopeless] at indicating whether a host is reachable.

You may as well ping the host directly, and catch a failure on a timeout.

Snips
  • 6,575
  • 7
  • 40
  • 64
0

just comment out the following line in Reachability.m if it is there.

 [super init];
iPhoneDev
  • 1,547
  • 2
  • 13
  • 36