Skip to content

Commit

Permalink
fix ios 11.3 crash
Browse files Browse the repository at this point in the history
  • Loading branch information
onezens committed Apr 6, 2018
1 parent b46e809 commit e370715
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions YCDownloadSession.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
};
D72C84CF1E77D42500EDCEEF = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = N62UU42592;
DevelopmentTeam = 6QXR4W42GG;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
Expand Down Expand Up @@ -787,7 +787,7 @@
D72C84E81E77D42500EDCEEF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = N62UU42592;
DEVELOPMENT_TEAM = 6QXR4W42GG;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/YCDownloadSession/ThirdLib/Bugly",
Expand All @@ -803,7 +803,7 @@
D72C84E91E77D42500EDCEEF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = N62UU42592;
DEVELOPMENT_TEAM = 6QXR4W42GG;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/YCDownloadSession/ThirdLib/Bugly",
Expand Down
4 changes: 2 additions & 2 deletions YCDownloadSession/YCDownloadSession/YCDownloadSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp
NSData *resumeData = [error.userInfo objectForKey:NSURLSessionDownloadTaskResumeData];
if (resumeData) {

float deviceVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (deviceVersion >= 11.0f && deviceVersion < 11.2f) {

if (YC_DEVICE_VERSION >= 11.0f && YC_DEVICE_VERSION < 11.2f) {
//修正iOS11 多次暂停继续 文件大小不对的问题
resumeData = [YCResumeData cleanResumeData:resumeData];
}
Expand Down
2 changes: 1 addition & 1 deletion YCDownloadSession/YCDownloadSession/YCDownloadTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef NS_ENUM(NSUInteger, YCDownloadStatus) {
YCDownloadStatusFinished,
YCDownloadStatusFailed
};
#define IS_IOS10ORLATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10)
#define YC_DEVICE_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
/**某一任务下载的状态发生变化的通知*/
static NSString * const kDownloadStatusChangedNoti = @"kDownloadStatusChangedNoti";

Expand Down
5 changes: 4 additions & 1 deletion YCDownloadSession/YCDownloadSession/YCDownloadTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ + (NSData *)correctRequestData:(NSData *)data
+ (NSMutableDictionary *)getResumeDictionary:(NSData *)data
{
NSMutableDictionary *iresumeDictionary = nil;
if (IS_IOS10ORLATER) {
if (YC_DEVICE_VERSION >= 10) {
id root = nil;
id keyedUnarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
@try {
Expand Down Expand Up @@ -435,6 +435,9 @@ + (NSMutableDictionary *)getResumeDictionary:(NSData *)data

+ (NSData *)correctResumeData:(NSData *)data
{
if (YC_DEVICE_VERSION >= 11.2) {
return data;
}
NSString *kResumeCurrentRequest = kNSURLSessionResumeCurrentRequest;
NSString *kResumeOriginalRequest = kNSURLSessionResumeOriginalRequest;
if (data == nil) {
Expand Down

0 comments on commit e370715

Please sign in to comment.