Skip to content

Commit

Permalink
FIX: random crash in YTKNetworkUtils because of multithread
Browse files Browse the repository at this point in the history
Change-Id: If8c920ba070646a00cde9bc44ec8c4dd69c31bdc
  • Loading branch information
joeshang committed Nov 1, 2019
1 parent ca6eb73 commit eb02979
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions YTKNetwork/YTKNetworkPrivate.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import <CommonCrypto/CommonDigest.h>
#import "YTKNetworkPrivate.h"

#if __has_include(<AFNetworking/AFNetworking.h>)
#if __has_include(<AFNetworking/AFURLRequestSerialization.h>)
#import <AFNetworking/AFURLRequestSerialization.h>
#else
#import "AFURLRequestSerialization.h"
Expand Down Expand Up @@ -123,8 +123,9 @@ + (NSString *)appVersionString {
+ (NSStringEncoding)stringEncodingWithRequest:(YTKBaseRequest *)request {
// From AFNetworking 2.6.3
NSStringEncoding stringEncoding = NSUTF8StringEncoding;
if (request.response.textEncodingName) {
CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)request.response.textEncodingName);
NSString *encodingName = [request.response.textEncodingName copy];
if (encodingName) {
CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)encodingName);
if (encoding != kCFStringEncodingInvalidId) {
stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
}
Expand Down

0 comments on commit eb02979

Please sign in to comment.