IOS gets the network status, and ios gets the network
For iOS developers, obtaining the network status is often used.
-(NSString *) getNetWorkStates {UIApplication * app = [UIApplication sharedApplication]; NSArray * children = [[app valueForKeyPath: @ "statusBar"] valueForKeyPath: @ "foregroundView"] subviews]; NSString * state = nil; int netType = 0; // obtain the network return code for (id child in children) {if ([child isKindOfClass: NSClassFromString (@ "UIStatusBarDataNetworkItemView")] {// obtain the status bar netType = [[child valueForKeyPath: @ "dataNetworkType"] intValue]; switch (netType) {case 0: state = @ "No network"; // No network mode break; case 1: state = @ "2G"; break; case 2: state = @ "3G"; break; case 3: state = @ "4G"; break; case 5: {state = @ "WIFI";} break; default: break ;}}} // select return state based on the status ;}