当前位置: 代码迷 >> Iphone >> 怎么判断iphone是否联网
  详细解决方案

怎么判断iphone是否联网

热度:74   发布时间:2016-04-25 06:22:12.0
如何判断iphone是否联网
+(BOOL)isNetworkReachable{ // Create zero addy struct sockaddr_in zeroAddress; bzero(&zeroAddress, sizeof(zeroAddress));zeroAddress.sin_len = sizeof(zeroAddress);zeroAddress.sin_family = AF_INET;// Recover reachability flags SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddres(NULL, (struct sockaddr *)&zeroAddress);SCNetworkReachabilityFlags flags; BOOL didRetrieveFlags = SCNetworkReachabilityGetFlag(defaultRouteReachability, &flags); CFRelease(defaultRouteReachability); if (!didRetrieveFlags) {                  return NO;               }}

?

  相关解决方案