[iOS]AFNetworking备忘录

@interface AFAppDotNetAPIClient : AFHTTPSessionManager
+ (instancetype)sharedClient;
@end
@implementation AFAppDotNetAPIClient
+ (instancetype)sharedClient {
    static AFAppDotNetAPIClient *_sharedClient = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedClient = [[AFAppDotNetAPIClient alloc] init];
        _sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
    });
    
    return _sharedClient;
}
@end
+ (instancetype)sharedClient;
@end

@implementation AFAppDotNetAPIClient
+ (instancetype)sharedClient {
    static AFAppDotNetAPIClient *_sharedClient = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedClient = [[AFAppDotNetAPIClient alloc] init];
        _sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
        _sharedClient.securityPolicy.allowInvalidCertificates = YES;
        _sharedClient.securityPolicy.validatesDomainName = NO;
        _sharedClient.securityPolicy.pinnedCertificates = [NSSet setWithObject:[NetHelper getCert]];
    });
    
    return _sharedClient;
}
@end

你可能感兴趣的:([iOS]AFNetworking备忘录)