Due to code privacy, I have to omit part of info. Just excuse me.
In TokenRequestManager.m
, there is an instance method serialQueue4TokenType
:
- (dispatch_queue_t)serialQueue4TokenType:(TokenType)tokenType
{
static NSMutableDictionary *serialQueueDict = nil;
if (serialQueueDict == nil) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
serialQueueDict = [[NSMutableDictionary alloc] initWithCapacity:TokenTypeCount];
});
}
dispatch_queue_t queue;
@synchronized (self) {
NSString *key = [TokenManager tokenName4Type:tokenType];
key = [key stringByAppendingString:NSStringFromClass([self class])];
NSValue *value = serialQueueDict[key];
if (value == nil) {
queue = dispatch_queue_create(key.UTF8String, DISPATCH_QUEUE_SERIAL);
value = [NSValue valueWithBytes:&queue objCType:@encode(dispatch_queue_t)];
serialQueueDict[key] = value;
} else {
[value getValue:&queue];
}
}
return queue;
}
Just below the @synchronized (self) {
line, it calls the Class method:
+ (NSString *)tokenName4Type:(TokenType)tokenType
{
NSString *string = nil;
switch (tokenType) {
case TokenTypeBiz:
return @"TokenTypeBiz";
break;
case TokenTypeWeb:
default:
string = @"TokenTypeWeb";
break;
}
return string;
}
The code just stands there, but sometimes (a few times) the app will crash at this line with unrecognized selector sent
, no matter debug or release.
Any tips will be much appreciated. Thanks.