title: unexpected non void return value in void function
body: <p>I've been pouring over stack overflow for ages trying to find a way out of this error:</p>
  
  <blockquote>
    <p>unexpected non void return value in void function</p>
  </blockquote>
  
  <p>that I am getting with returning a <code>Bool</code> within my function.  </p>
  
  <p>i just can't seem to dig my way out of this one.  I'm sure its something to do with async but I'm not very familiar with these types of functions.</p>
  
  <pre><code>class CheckReachability {
  
  
      class func setupReachability (hostName:String?, useClosures: Bool) -&gt; Bool{
  
          var reachability : Reachability!
          var connected = false
  
                  let reachability2 = hostName == nil ? Reachability() : Reachability(hostname: hostName!)
                  reachability = reachability2
                  try! reachability?.startNotifier()
  
                  if useClosures {
                      reachability2?.whenReachable = { reachability in
                          DispatchQueue.main.async {
                              connected = true
                              print("Reachable....")
                          }
                      }
                      reachability2?.whenUnreachable = { reachability in
                          DispatchQueue.main.async {
                              connected = false
                              print("Not Connected....")
                          }
                      }
  
                  } else {
                      NotificationCenter.default.addObserver(self, selector: Selector(("reachabilityChanged:")), name: ReachabilityChangedNotification, object: reachability2)
                  }
              return connected
              }
  
  }
  </code></pre>
  
  <p>calling this from viewdidload on another vc doesn't allow enough time to get a true result</p>
  
  <pre><code>        let connected = CheckReachability.setupReachability(hostName: nil, useClosures: true)
  if connected {
  </code></pre>