title: how to block user , if he/she not connected to internet connection when my app load
body: <p>I have one app, which is fully map view.What I need is I need to show some alert if user not connected to internet . I have done that. Here is the code :</p>
  
  <pre><code>Reachability.swift.
  
  import Foundation
  import SystemConfiguration
  
  public class Reachability {
  
      class func isConnectedToNetwork() -&gt; Bool {
  
          var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
          zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
          zeroAddress.sin_family = sa_family_t(AF_INET)
  
          let defaultRouteReachability = withUnsafePointer(&amp;zeroAddress) {
              SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, UnsafePointer($0))
          }
  
          var flags: SCNetworkReachabilityFlags = SCNetworkReachabilityFlags(rawValue: 0)
          if SCNetworkReachabilityGetFlags(defaultRouteReachability!, &amp;flags) == false {
               return false
          }
  
          let isReachable = flags == .Reachable
          let needsConnection = flags == .ConnectionRequired
  
          return isReachable &amp;&amp; !needsConnection
  
      }
  }
  if Reachability.isConnectedToNetwork() == true {
      println("Internet connection OK")
  } else {
      println("Internet connection FAILED")
      var alert = UIAlertView(title: "No Internet Connection", message: "Make sure your device is connected to the internet.", delegate: nil, cancelButtonTitle: "OK")
      alert.show()
  }
  </code></pre>
  
  <p>But what I need is : when user not connected to internet , one <code>UIAlertView</code> message will show. in that alert I have one <code>OK</code> button. So till user connect to internet , it is possible to redirect them to mobile data on/off settings or it is possible to show <code>UIAlertView</code> message till the user connect to internet..</p>
  
  <p>Please help me out !!</p>