+(
NSString
*)getNetWorkStates{
UIApplication *app = [ UIApplication sharedApplication ];
NSArray *children = [[[app valueForKeyPath : @"statusBar" ] valueForKeyPath : @"foregroundView" ] subviews ];
NSString *state = [[ NSString alloc ] init ];
int netType = 0 ;
// 获取到网络返回码
for ( id child in children) {
if ([child isKindOfClass : NSClassFromString ( @"UIStatusBarDataNetworkItemView" )]) {
// 获取到状态栏
netType = [[child valueForKeyPath : @"dataNetworkType" ] intValue ];
switch (netType) {
case 0 :
state = @" 无网络 " ;
// 无网模式
break ;
case 1 :
state = @"2G" ;
break ;
case 2 :
state = @"3G" ;
break ;
case 3 :
state = @"4G" ;
break ;
case 5 :
{
state = @"WIFI" ;
}
break ;
default :
break ;
}
}
}
// 根据状态选择
return state;
UIApplication *app = [ UIApplication sharedApplication ];
NSArray *children = [[[app valueForKeyPath : @"statusBar" ] valueForKeyPath : @"foregroundView" ] subviews ];
NSString *state = [[ NSString alloc ] init ];
int netType = 0 ;
// 获取到网络返回码
for ( id child in children) {
if ([child isKindOfClass : NSClassFromString ( @"UIStatusBarDataNetworkItemView" )]) {
// 获取到状态栏
netType = [[child valueForKeyPath : @"dataNetworkType" ] intValue ];
switch (netType) {
case 0 :
state = @" 无网络 " ;
// 无网模式
break ;
case 1 :
state = @"2G" ;
break ;
case 2 :
state = @"3G" ;
break ;
case 3 :
state = @"4G" ;
break ;
case 5 :
{
state = @"WIFI" ;
}
break ;
default :
break ;
}
}
}
// 根据状态选择
return state;
}
#pragma mark
#pragma 获取当前的ssid
- (
NSString
*)CurrentSSIDInfo {
NSArray
*ifs = (__bridge_transfer
id
)CNCopySupportedInterfaces();
NSLog
(@
"Supported interfaces: %@"
, ifs);
id
info =
nil
;
for
(
NSString
*ifnam in ifs) {
info = (__bridge_transfer
id
)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog
(@
"%@ => %@"
, ifnam, info);
if
(info && [info count]) {
break
; }
}
return
[[(
NSDictionary
*)info objectForKey:@
"SSID"
] lowercaseString];
}
2
3
4
5
6
7
8
9
10
11
12
13
#pragma mark
#pragma 获取当前的ssid
- (
NSString
*)CurrentSSIDInfo {
NSArray
*ifs = (__bridge_transfer
id
)CNCopySupportedInterfaces();
NSLog
(@
"Supported interfaces: %@"
, ifs);
id
info =
nil
;
for
(
NSString
*ifnam in ifs) {
info = (__bridge_transfer
id
)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog
(@
"%@ => %@"
, ifnam, info);
if
(info && [info count]) {
break
; }
}
return
[[(
NSDictionary
*)info objectForKey:@
"SSID"
] lowercaseString];
}
2
3
4
5
6
7
8
9
10
11
12
13
#pragma mark
#pragma 获取当前的ssid
- (
NSString
*)CurrentSSIDInfo {
NSArray
*ifs = (__bridge_transfer
id
)CNCopySupportedInterfaces();
NSLog
(@
"Supported interfaces: %@"
, ifs);
id
info =
nil
;
for
(
NSString
*ifnam in ifs) {
info = (__bridge_transfer
id
)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog
(@
"%@ => %@"
, ifnam, info);
if
(info && [info count]) {
break
; }
}
return
[[(
NSDictionary
*)info objectForKey:@
"SSID"
] lowercaseString];
}
2
3
4
5
6
7
8
9
10
11
12
13
#pragma mark
#pragma 获取当前的ssid
- (
NSString
*)CurrentSSIDInfo {
NSArray
*ifs = (__bridge_transfer
id
)CNCopySupportedInterfaces();
NSLog
(@
"Supported interfaces: %@"
, ifs);
id
info =
nil
;
for
(
NSString
*ifnam in ifs) {
info = (__bridge_transfer
id
)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog
(@
"%@ => %@"
, ifnam, info);
if
(info && [info count]) {
break
; }
}
return
[[(
NSDictionary
*)info objectForKey:@
"SSID"
] lowercaseString];
}