判断网络状态公共类

来源:互联网 发布:百度语音识别 python 编辑:程序博客网 时间:2024/05/20 02:56
#import <Foundation/Foundation.h>@interface Utility : NSObject/** *  判断是否有网络,YES表示有 * *  @return <#return value description#> */+ (BOOL)isNetWorkReachility;@end
#import "Utility.h"#import "Reachability.h"@implementation Utility/** *  判断是否有网络,YES表示有 * *  @return <#return value description#> */+ (BOOL)isNetWorkReachility{    //域名    Reachability *reachability = [Reachability reachabilityWithHostname:@"www.baidu.com"];    //获取当前网络的状态    NetworkStatus status = [reachability currentReachabilityStatus];        //没有网络    if (status == NotReachable)    {        return NO;    }        return YES;}@end


0 0
原创粉丝点击