-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHYChainRequestAgent.m
More file actions
54 lines (44 loc) · 1009 Bytes
/
HYChainRequestAgent.m
File metadata and controls
54 lines (44 loc) · 1009 Bytes
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
46
47
48
49
50
51
52
53
54
//
// HYChainRequestAgent.m
// YTKNetworkDemo
//
// Created by zheng on 2017/8/16.
// Copyright © 2017年 yuantiku.com. All rights reserved.
//
#import "HYChainRequestAgent.h"
#import "HYChainRequest.h"
@interface HYChainRequestAgent()
@property (strong, nonatomic) NSMutableArray<HYChainRequest *> *requestArray;
@end
@implementation HYChainRequestAgent
+ (HYChainRequestAgent *)sharedAgent
{
static id sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
- (instancetype)init
{
self = [super init];
if (self)
{
_requestArray = [NSMutableArray array];
}
return self;
}
- (void)addChainRequest:(HYChainRequest *)request
{
@synchronized(self) {
[_requestArray addObject:request];
}
}
- (void)removeChainRequest:(HYChainRequest *)request
{
@synchronized(self) {
[_requestArray removeObject:request];
}
}
@end