网络工具类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#import "AFHTTPRequestOperationManager.h"
 
@interface NetworkTools : AFHTTPRequestOperationManager
 
+ (instancetype)shareNetworkTools;
@end
 
#import "NetworkTools.h"
 
@implementation NetworkTools
 
+ (instancetype)shareNetworkTools
{
    static id instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        NSURL *url = [NSURL URLWithString:@"http://xxxxxxx/"];
        instance = [[self alloc] initWithBaseURL:url];
    });
    return instance;
}
@end
 
#import "AFHTTPSessionManager.h"
 
@interface NetworkTools2 : AFHTTPSessionManager
+ (instancetype)shareNetworkTools;
@end
 
 
#import "NetworkTools2.h"
 
@implementation NetworkTools2
+ (instancetype)shareNetworkTools
{
    static id instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        // 注意: 在指定baseURL的时候, 后面需要加上/
        NSURL *url = [NSURL URLWithString:@"http://xxxxxxxxx/"];
        instance = [[self alloc] initWithBaseURL:url sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    });
    return instance;
}
@end

 

posted @   Show撑腰  阅读(149)  评论(0编辑  收藏  举报
编辑推荐:
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
阅读排行:
· 本地部署 DeepSeek:小白也能轻松搞定!
· 如何给本地部署的DeepSeek投喂数据,让他更懂你
· 从 Windows Forms 到微服务的经验教训
· 李飞飞的50美金比肩DeepSeek把CEO忽悠瘸了,倒霉的却是程序员
· 超详细,DeepSeek 接入PyCharm实现AI编程!(支持本地部署DeepSeek及官方Dee
点击右上角即可分享
微信分享提示