iOS 判断是否连接wifi
2016-06-21 09:28
483 查看
+(BOOL)isWIFIConnection;
+(BOOL)isWIFIConnection
{
BOOL ret = YES;
struct ifaddrs * first_ifaddr, * current_ifaddr;
NSMutableArray* activeInterfaceNames = [[NSMutableArray
alloc] init];
getifaddrs( &first_ifaddr );
current_ifaddr = first_ifaddr;
while( current_ifaddr!=NULL )
{
if( current_ifaddr->ifa_addr->sa_family==0x02 )
{
[activeInterfaceNames addObject:[NSString
stringWithFormat:@"%s", current_ifaddr->ifa_name]];
}
current_ifaddr = current_ifaddr->ifa_next;
}
ret = [activeInterfaceNames containsObject:@"en0"] || [activeInterfaceNames
containsObject:@"en1"];
return ret;
}
+(BOOL)isWIFIConnection
{
BOOL ret = YES;
struct ifaddrs * first_ifaddr, * current_ifaddr;
NSMutableArray* activeInterfaceNames = [[NSMutableArray
alloc] init];
getifaddrs( &first_ifaddr );
current_ifaddr = first_ifaddr;
while( current_ifaddr!=NULL )
{
if( current_ifaddr->ifa_addr->sa_family==0x02 )
{
[activeInterfaceNames addObject:[NSString
stringWithFormat:@"%s", current_ifaddr->ifa_name]];
}
current_ifaddr = current_ifaddr->ifa_next;
}
ret = [activeInterfaceNames containsObject:@"en0"] || [activeInterfaceNames
containsObject:@"en1"];
return ret;
}
相关文章推荐
- iOS 判断身份证号码
- iOS 根据生日(单位秒)转换成一个年龄
- iOS pch中或者common.h中常见的代码
- MVC's Blind Structure Way
- iOS利用AFNetworking(AFN) 实现图片上传
- iOS支付宝支付
- iOS用户是否开启定位服务
- ios Symbol(s) not found for architecture arm64总结 含隐藏错误cocoapods
- iOS获取 移动设备型号
- iOS 基础篇13- 通知的使用
- iOS Base64加密
- ios 学习动画的套路 (一)
- iOS计算缓存内容大小
- iOS 基础篇12- 定时器的使用
- IOS开发系列--TableView、多个TableViewCell、自定义Cell、Cell上画画(故事板+代码方式),ios7tableview索引
- 当连接iOS设备照相机时禁止打开照片Photos等程序
- iOS开发实战——CollectionView中cell的间距设置
- iOS 获取屏幕的朝向
- iOS 传感器(加速计 + 陀螺仪)
- iOS中的动画