+ (instancetype)sharedClient { static APIClient *_sharedClient = nil; static dispatch_once_t onceToken; NSString * APIBaseURLString = [NSString stringWithFormat:SERVER_INTERFACES, SERVER_IP]; ; dispatch_once(&onceToken, ^{ _sharedClient = [[APIClient alloc] initWithBaseURL:[NSURL URLWithString:VWAPIBaseURLString]]; [_sharedClient setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey]]; [_sharedClient.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { switch (status) { case AFNetworkReachabilityStatusReachableViaWWAN: [Dialog simpleToast:@"网络已连接"]; break; case AFNetworkReachabilityStatusReachableViaWiFi: [Dialog simpleToast:@"网络已连接"]; break; case AFNetworkReachabilityStatusNotReachable: [Dialog simpleToast:@"当前网络不可用,请联系管理员"]; break; default: break; } }]; [_sharedClient.reachabilityManager startMonitoring]; }); return _sharedClient; }