小编Bha*_*mar的帖子

使用两个不同的baseUrl - AFHTTPSessionManager

我正在使用AFHTTPSessionManager在网上进行api调用.我有会话管理器的signleton对象,它启动一次基本URL.偶尔,我需要用不同的baseurl进行api调用.它的只读在AFNetworking.h文件中.

在这里处理不同基础的正确方法是什么?请帮助.

+ (ApiClient *)sharedClient {

    static ApiClient *_sharedClient = nil;

    static dispatch_once_t oncePredicate;

    dispatch_once(&oncePredicate, ^{
        _sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:kTraktBaseURLString]];
    });
    return _sharedClient;
}
Run Code Online (Sandbox Code Playgroud)

objective-c afnetworking-2

4
推荐指数
1
解决办法
1135
查看次数

标签 统计

afnetworking-2 ×1

objective-c ×1