Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have two code errors that will prevent your code from working.</p> <p>First, your call to 'start monitoring' occurs inside the block that is fired in response to reachability changes -- therefore, the block will never fire (unless you start monitoring elsewhere).</p> <p>Second, there are no guarantees on when that block will fire. As a result, you'll always see 'reachable' return whatever value it was initialized to -- apparently this is usually null. Even if you fix the first error, there's no guarantee (and it's actually rather unlikely) that the block will fire before you return.</p> <p>Finally, on a more general level, you're also trying to test in a synchronous manner code that can <em>only</em> be executed asynchronously. Which is to say, it's impossible for the reachability manager to accurately determine reachability instantaneously. It can say 'I think I'm on WiFi' or 'I think I'm on 3G', but it also needs to check to see if it can actually <em>reach</em> the internet (hence the name reachability) before it can be certain. Reachability isn't just about 'I have a wifi' or 'I have a 3g' connection, it's also about whether you can reach the internet through it. This means the device actually has to send a request, and while this can, technically, be done in a synchronous manner, every single rule in the book insists that network code <em>must</em> be done asynchronously, and for good reason. If you did is synchronously, you'd block your UI until the network call returns... possibly a good 30, 40, 50, even 60 seconds later, depending on the relevant timeouts.</p> <p>What you should do is start the reachability singleton monitoring in your app did load method of the app delegate, then retrieve it's data later. Without knowing the structure of your app I won't even try to guarantee accuracy, but that should at least help, somewhat.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload