ios - Network Connection Checker via Reachability class swift 2.0 -


i trying check internet connection status via reachability.swift class has written in swift 2.0. here class code:

import uikit import foundation import systemconfiguration  public class reachability: nsobject {      class func isconnectedtonetwork() -> 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(&zeroaddress) {             scnetworkreachabilitycreatewithaddress(kcfallocatordefault, unsafepointer($0))         }          var flags: scnetworkreachabilityflags = scnetworkreachabilityflags(rawvalue: 0)         if scnetworkreachabilitygetflags(defaultroutereachability!, &flags) == false {             return false         }          let isreachable = flags == .reachable         let needsconnection = flags == .connectionrequired          return (isreachable && !needsconnection)      } } 

my question this; when connected cellular network class not recognise means isconnectedtonetwork() method returns false on iphone 5 device, not simulator. situation there? please ant appreciated, thanx...

along reachable , connectionrequired need check too.

let iswan = flags = .iswwan 

if either of reachable or iswwan set connected network. iswwan tells if specified node name or address can reached via cellular connection, such edge or gprs.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -