Steven пре 5 година
родитељ
комит
be21e57205

+ 4 - 0
MusicGradeExam/MusicGradeExam.xcodeproj/project.pbxproj

@@ -373,6 +373,7 @@
 		2729F7C924C6EB4A00E1F3C4 /* SubjectNameModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SubjectNameModel.m; sourceTree = "<group>"; };
 		2729F7C924C6EB4A00E1F3C4 /* SubjectNameModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SubjectNameModel.m; sourceTree = "<group>"; };
 		2729F7CB24C6F3F300E1F3C4 /* SongListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SongListModel.h; sourceTree = "<group>"; };
 		2729F7CB24C6F3F300E1F3C4 /* SongListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SongListModel.h; sourceTree = "<group>"; };
 		2729F7CC24C6F3F300E1F3C4 /* SongListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SongListModel.m; sourceTree = "<group>"; };
 		2729F7CC24C6F3F300E1F3C4 /* SongListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SongListModel.m; sourceTree = "<group>"; };
+		2729F7CE24C7D43600E1F3C4 /* 酷乐秀.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "酷乐秀.entitlements"; sourceTree = "<group>"; };
 		27476F4324BBFB5900181362 /* 酷乐秀.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "酷乐秀.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		27476F4324BBFB5900181362 /* 酷乐秀.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "酷乐秀.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		27476F4624BBFB5900181362 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		27476F4624BBFB5900181362 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		27476F4724BBFB5900181362 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
 		27476F4724BBFB5900181362 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -1082,6 +1083,7 @@
 		27476F4524BBFB5900181362 /* MusicGradeExam */ = {
 		27476F4524BBFB5900181362 /* MusicGradeExam */ = {
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
+				2729F7CE24C7D43600E1F3C4 /* 酷乐秀.entitlements */,
 				2747718624BC0C0400181362 /* KSRequestManager.h */,
 				2747718624BC0C0400181362 /* KSRequestManager.h */,
 				2747700224BC0C0000181362 /* KSRequestManager.m */,
 				2747700224BC0C0000181362 /* KSRequestManager.m */,
 				2747707524BC0C0200181362 /* Manager */,
 				2747707524BC0C0200181362 /* Manager */,
@@ -3244,6 +3246,7 @@
 			baseConfigurationReference = 2F7D3758362ED28D51286A60 /* Pods-MusicGradeExam.debug.xcconfig */;
 			baseConfigurationReference = 2F7D3758362ED28D51286A60 /* Pods-MusicGradeExam.debug.xcconfig */;
 			buildSettings = {
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CODE_SIGN_ENTITLEMENTS = "MusicGradeExam/酷乐秀.entitlements";
 				CODE_SIGN_STYLE = Automatic;
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1.0.0;
 				CURRENT_PROJECT_VERSION = 1.0.0;
 				DEVELOPMENT_TEAM = 2K89M44X82;
 				DEVELOPMENT_TEAM = 2K89M44X82;
@@ -3278,6 +3281,7 @@
 			baseConfigurationReference = 1AA4DFCEF527585287BEBFE0 /* Pods-MusicGradeExam.release.xcconfig */;
 			baseConfigurationReference = 1AA4DFCEF527585287BEBFE0 /* Pods-MusicGradeExam.release.xcconfig */;
 			buildSettings = {
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				CODE_SIGN_ENTITLEMENTS = "MusicGradeExam/酷乐秀.entitlements";
 				CODE_SIGN_STYLE = Automatic;
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1.0.0;
 				CURRENT_PROJECT_VERSION = 1.0.0;
 				DEVELOPMENT_TEAM = 2K89M44X82;
 				DEVELOPMENT_TEAM = 2K89M44X82;

+ 4 - 0
MusicGradeExam/MusicGradeExam/KSRequestManager.h

@@ -68,8 +68,12 @@ NS_ASSUME_NONNULL_BEGIN
 
 
 
 
 #pragma mark ---- 文件下载
 #pragma mark ---- 文件下载
+// 单文件下载
 + (void)downloadFileRequestWithFileUrl:(NSString *)url progress:(void (^)(int64_t bytesRead, int64_t totalBytes))progress success:(void(^)(NSURL *fileUrl))success faliure:(void (^)(NSError * error))faliure;
 + (void)downloadFileRequestWithFileUrl:(NSString *)url progress:(void (^)(int64_t bytesRead, int64_t totalBytes))progress success:(void(^)(NSURL *fileUrl))success faliure:(void (^)(NSError * error))faliure;
 
 
+// 多文件下载
++ (void)mutiDownloadFileRequest:(NSArray *)fileUrl progress:(void (^)(int64_t bytesRead, int64_t totalBytes))progress success:(void(^)(NSArray *dics))success faliure:(void(^)(NSError *error))faliure;
+
 #pragma mark ---- 验证码服务
 #pragma mark ---- 验证码服务
 // /api-auth/code/sendSms
 // /api-auth/code/sendSms
 
 

+ 19 - 1
MusicGradeExam/MusicGradeExam/KSRequestManager.m

@@ -252,6 +252,22 @@
     }];
     }];
 }
 }
 
 
+// 多文件下载
++ (void)mutilDownTaskWithUrl:(NSArray *)urlArray
+                    progress:(void(^)(int64_t bytesRead, int64_t totalBytes))progress
+                successBlock:(void(^)(NSMutableArray *dics))success
+                   failBlock:(void(^)(NSError *error))faliure {
+    [[KSNetworking shareManager] downloadMutilFileWithUrl:urlArray progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
+        
+    } successBlock:^(NSArray * _Nonnull responses) {
+        NSMutableArray *result = [NSMutableArray arrayWithArray:responses];
+        success(result);
+    } failBlock:^(NSArray * _Nonnull errors) {
+        [self showMessage:@"网络或服务器错误,请重试"];
+        faliure([errors lastObject]);
+    }];
+}
+
 #pragma mark --- 图片上传
 #pragma mark --- 图片上传
 
 
 /// 图片上传
 /// 图片上传
@@ -314,7 +330,9 @@
     [self downloadTaskWithUrl:url progress:progress success:success faliure:faliure];
     [self downloadTaskWithUrl:url progress:progress success:success faliure:faliure];
 }
 }
 
 
-
++ (void)mutiDownloadFileRequest:(NSArray *)fileUrl progress:(void (^)(int64_t, int64_t))progress success:(void (^)(NSArray * _Nonnull))success faliure:(void (^)(NSError * _Nonnull))faliure {
+    [self mutilDownTaskWithUrl:fileUrl progress:progress successBlock:success failBlock:faliure];
+}
 
 
 #pragma mark ---- 验证码服务
 #pragma mark ---- 验证码服务
 // /api-auth/code/sendSms
 // /api-auth/code/sendSms

+ 16 - 12
MusicGradeExam/MusicGradeExam/Tools/NetworkManager/Cache/KSCacheManager.m

@@ -20,6 +20,7 @@ static NSUInteger diskCapacity = 40 * 1024 * 1024;
 
 
 static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 
 
+#define CACHE_PATH ([NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject])
 @implementation KSCacheManager
 @implementation KSCacheManager
 
 
 + (KSCacheManager *)shareManager {
 + (KSCacheManager *)shareManager {
@@ -64,10 +65,11 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
         NSString *directoryPath = nil;
         NSString *directoryPath = nil;
         directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
         directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
         if (!directoryPath) {
         if (!directoryPath) {
-            directoryPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"YQNetworking"] stringByAppendingPathComponent:@"networkCache"];
+            directoryPath = @"KSNetworking/networkCache";
             [[NSUserDefaults standardUserDefaults] setObject:directoryPath forKey:cacheDirKey];
             [[NSUserDefaults standardUserDefaults] setObject:directoryPath forKey:cacheDirKey];
             [[NSUserDefaults standardUserDefaults] synchronize];
             [[NSUserDefaults standardUserDefaults] synchronize];
         }
         }
+        directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
         [KSDiskCache writeData:data toDir:directoryPath filename:hash];
         [KSDiskCache writeData:data toDir:directoryPath filename:hash];
         
         
         [[KSLRUManager shareManager] addFileNode:hash];
         [[KSLRUManager shareManager] addFileNode:hash];
@@ -90,7 +92,7 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
     
     
     if (!cacheData) {
     if (!cacheData) {
         NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
         NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
-        
+        directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
         if (directoryPath) {
         if (directoryPath) {
             cacheData = [KSDiskCache readDataFromDir:directoryPath filename:hash];
             cacheData = [KSDiskCache readDataFromDir:directoryPath filename:hash];
             
             
@@ -125,13 +127,12 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
     NSString *directoryPath = nil;
     NSString *directoryPath = nil;
     directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
     directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
     if (!directoryPath) {
     if (!directoryPath) {
-        directoryPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"YQNetworking"] stringByAppendingPathComponent:@"download"];
-        
+        directoryPath = @"KSNetworking/download";
         [[NSUserDefaults standardUserDefaults] setObject:directoryPath forKey:downloadDirKey];
         [[NSUserDefaults standardUserDefaults] setObject:directoryPath forKey:downloadDirKey];
         [[NSUserDefaults standardUserDefaults] synchronize];
         [[NSUserDefaults standardUserDefaults] synchronize];
     }
     }
     
     
-    
+    directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
     [KSDiskCache writeData:data toDir:directoryPath filename:fileName];
     [KSDiskCache writeData:data toDir:directoryPath filename:fileName];
     
     
 }
 }
@@ -159,7 +160,7 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
     
     
     
     
     NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
     NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
-    
+    directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
     if (directoryPath) data = [KSDiskCache readDataFromDir:directoryPath filename:fileName];
     if (directoryPath) data = [KSDiskCache readDataFromDir:directoryPath filename:fileName];
     
     
     if (data) {
     if (data) {
@@ -171,36 +172,38 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
 }
 }
 
 
 - (NSUInteger)totalCacheSize {
 - (NSUInteger)totalCacheSize {
-    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey: cacheDirKey];
-    
+    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
+    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
     return [KSDiskCache dataSizeInDir:diretoryPath];
     return [KSDiskCache dataSizeInDir:diretoryPath];
 }
 }
 
 
 - (NSUInteger)totalDownloadDataSize {
 - (NSUInteger)totalDownloadDataSize {
-    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey: downloadDirKey];
-    
+    NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
+    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
     return [KSDiskCache dataSizeInDir:diretoryPath];
     return [KSDiskCache dataSizeInDir:diretoryPath];
 }
 }
 
 
 - (void)clearDownloadData {
 - (void)clearDownloadData {
     NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
     NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
-    
+    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
     [KSDiskCache clearDataIinDir:diretoryPath];
     [KSDiskCache clearDataIinDir:diretoryPath];
 }
 }
 
 
 - (NSString *)getDownDirectoryPath {
 - (NSString *)getDownDirectoryPath {
     NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
     NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:downloadDirKey];
+    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
     return diretoryPath;
     return diretoryPath;
 }
 }
 
 
 - (NSString *)getCacheDiretoryPath {
 - (NSString *)getCacheDiretoryPath {
     NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
     NSString *diretoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
+    diretoryPath = [CACHE_PATH stringByAppendingPathComponent:diretoryPath];
     return diretoryPath;
     return diretoryPath;
 }
 }
 
 
 - (void)clearTotalCache {
 - (void)clearTotalCache {
     NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
     NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
-    
+    directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
     [KSDiskCache clearDataIinDir:directoryPath];
     [KSDiskCache clearDataIinDir:directoryPath];
 }
 }
 
 
@@ -208,6 +211,7 @@ static NSTimeInterval cacheTime = 7 * 24 * 60 * 60;
     if ([self totalCacheSize] > diskCapacity) {
     if ([self totalCacheSize] > diskCapacity) {
         NSArray *deleteFiles = [[KSLRUManager shareManager] removeLRUFileNodeWithCacheTime:cacheTime];
         NSArray *deleteFiles = [[KSLRUManager shareManager] removeLRUFileNodeWithCacheTime:cacheTime];
         NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
         NSString *directoryPath = [[NSUserDefaults standardUserDefaults] objectForKey:cacheDirKey];
+        directoryPath = [CACHE_PATH stringByAppendingPathComponent:directoryPath];
         if (directoryPath && deleteFiles.count > 0) {
         if (directoryPath && deleteFiles.count > 0) {
             [deleteFiles enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
             [deleteFiles enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
                 NSString *filePath = [directoryPath stringByAppendingPathComponent:obj];
                 NSString *filePath = [directoryPath stringByAppendingPathComponent:obj];

+ 12 - 1
MusicGradeExam/MusicGradeExam/Tools/NetworkManager/KSNetworking.h

@@ -237,7 +237,7 @@ NS_ASSUME_NONNULL_BEGIN
  *  @param url           下载文件接口地址
  *  @param url           下载文件接口地址
  *  @param progressBlock 下载进度
  *  @param progressBlock 下载进度
  *  @param successBlock  成功回调
  *  @param successBlock  成功回调
- *  @param failBlock     下载回调
+ *  @param failBlock     失败回调
  *
  *
  *  @return 返回的对象可取消请求
  *  @return 返回的对象可取消请求
  */
  */
@@ -246,6 +246,17 @@ NS_ASSUME_NONNULL_BEGIN
                          successBlock:(KSDownloadSuccessBlock _Nullable)successBlock
                          successBlock:(KSDownloadSuccessBlock _Nullable)successBlock
                             failBlock:(KSDownloadFailBlock _Nullable)failBlock;
                             failBlock:(KSDownloadFailBlock _Nullable)failBlock;
 
 
+
+/// 多文件下载
+/// @param urlArray 下载文件链接
+/// @param progressBlock 下载进度
+/// @param successBlock 成功回调
+/// @param failBlock 失败回调
+- (NSArray *_Nonnull)downloadMutilFileWithUrl:(NSArray *_Nonnull)urlArray
+                                progressBlock:(KSDownloadProgress _Nullable)progressBlock
+                                 successBlock:(KSMultUploadSuccessBlock _Nullable)successBlock
+                                    failBlock:(KSMultUploadFailBlock _Nullable)failBlock;
+
 @end
 @end
 
 
 
 

+ 66 - 2
MusicGradeExam/MusicGradeExam/Tools/NetworkManager/KSNetworking.m

@@ -13,7 +13,7 @@
 
 
 #define YQ_ERROR_IMFORMATION @"网络出现错误,请检查网络连接"
 #define YQ_ERROR_IMFORMATION @"网络出现错误,请检查网络连接"
 
 
-#define YQ_ERROR [NSError errorWithDomain:@"com.hyq.YQNetworking.ErrorDomain" code:-999 userInfo:@{ NSLocalizedDescriptionKey:YQ_ERROR_IMFORMATION}]
+#define YQ_ERROR [NSError errorWithDomain:@"com.hyq.KSNetworking.ErrorDomain" code:-999 userInfo:@{ NSLocalizedDescriptionKey:YQ_ERROR_IMFORMATION}]
 
 
 
 
 static NSMutableArray   *requestTasksPool;
 static NSMutableArray   *requestTasksPool;
@@ -22,7 +22,7 @@ static NSDictionary     *headers;
 
 
 static KSNetworkStatus  networkStatus;
 static KSNetworkStatus  networkStatus;
 
 
-static NSTimeInterval   requestTimeout = 220.0f;  // 超时时间
+static NSTimeInterval   requestTimeout = 30.0f;  // 超时时间
 
 
 @interface KSNetworking ()
 @interface KSNetworking ()
 
 
@@ -408,6 +408,70 @@ static NSTimeInterval   requestTimeout = 220.0f;  // 超时时间
     return session;
     return session;
 }
 }
 
 
+#pragma mark ----- 多文件下载
+- (NSArray *)downloadMutilFileWithUrl:(NSArray *)urlArray
+                        progressBlock:(KSDownloadProgress)progressBlock
+                         successBlock:(KSMultUploadSuccessBlock)successBlock
+                            failBlock:(KSMultUploadFailBlock)failBlock {
+    if (networkStatus == KSNetworkStatusNotReachable) {
+        if (failBlock) failBlock(@[YQ_ERROR]);
+        return nil;
+    }
+    
+    __block NSMutableArray *sessions = [NSMutableArray array];
+    __block NSMutableArray *responses = [NSMutableArray array];
+    __block NSMutableArray *failResponse = [NSMutableArray array];
+    
+    dispatch_group_t downGroup = dispatch_group_create();
+    
+    NSInteger count = urlArray.count;
+    for (int i = 0; i < count; i++) {
+        __block KSURLSessionTask *session = nil;
+        dispatch_group_enter(downGroup);
+        session = [self downloadWithUrl:urlArray[i] progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
+            if (progressBlock) progressBlock(bytesRead,
+            totalBytes);
+        } successBlock:^(NSURL * _Nullable url) {
+            [responses addObject:url];
+            
+            dispatch_group_leave(downGroup);
+            [sessions removeObject:session];
+            
+        } failBlock:^(NSError * _Nonnull error) {
+            NSError *Error = [NSError errorWithDomain:urlArray[i] code:-999 userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"第%d次下载失败",i]}];
+
+            [failResponse addObject:Error];
+            dispatch_group_leave(downGroup);
+            [sessions removeObject:session];
+        }];
+        
+        [session resume];
+        if (session) [sessions addObject:session];
+    }
+    
+    [[KSNetworking allTasks] addObjectsFromArray:sessions];
+    dispatch_group_notify(downGroup, dispatch_get_main_queue(), ^{
+        if (responses.count > 0) {
+            if (successBlock) {
+                successBlock([responses copy]);
+                if (sessions.count > 0) {
+                    [[KSNetworking allTasks] removeObjectsInArray:sessions];
+                }
+            }
+        }
+        
+        if (failResponse.count > 0) {
+            if (failBlock) {
+                failBlock([failResponse copy]);
+                if (sessions.count > 0) {
+                    [[KSNetworking allTasks] removeObjectsInArray:sessions];
+                }
+            }
+        }
+    });
+    return [sessions copy];
+}
+
 #pragma mark - other method
 #pragma mark - other method
 - (void)setupTimeout:(NSTimeInterval)timeout {
 - (void)setupTimeout:(NSTimeInterval)timeout {
     requestTimeout = timeout;
     requestTimeout = timeout;

+ 7 - 4
MusicGradeExam/MusicGradeExam/UI/ExamLibrary/Controller/ExamLibraryController.m

@@ -191,10 +191,13 @@
 
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     SongListModel *model = self.dataArray[indexPath.row];
     SongListModel *model = self.dataArray[indexPath.row];
-    OpenFileViewController *fileUrl = [[OpenFileViewController alloc] init];
-//    model.fileUrlList 
-    fileUrl.urlString = @"https://www.tutorialspoint.com/ios/ios_tutorial.pdf";
-    [self.navigationController pushViewController:fileUrl animated:YES];
+    if ([NSString isEmptyString:model.fileUrlList]) {
+        [self MBPShow:@"曲库链接错误"];
+        return;
+    }
+    OpenFileViewController *readCtrl = [[OpenFileViewController alloc] init];
+    readCtrl.urlString = model.fileUrlList;
+    [self.navigationController pushViewController:readCtrl animated:YES];
 }
 }
 
 
 - (UITableView *)tableView {
 - (UITableView *)tableView {

+ 16 - 71
MusicGradeExam/MusicGradeExam/UI/ExamLibrary/Controller/OpenFileViewController.m

@@ -13,9 +13,8 @@
 
 
 @property (nonatomic, strong) QLPreviewController *previewCtrl;
 @property (nonatomic, strong) QLPreviewController *previewCtrl;
 
 
-@property (nonatomic, strong) NSURL *fileURL;
 
 
-@property (nonatomic, strong) MBProgressHUD *hud;
+@property (nonatomic, strong) NSMutableArray *fileArray;
 
 
 @end
 @end
 
 
@@ -35,34 +34,29 @@
     [self requestFileSource];
     [self requestFileSource];
 }
 }
 
 
-- (void)requestFileSource {
-    if ([self isFileExist:self.urlString]) { // 本地加载
-        self.fileURL = [self getSavePath:self.urlString];
-        //刷新界面,如果不刷新的话,不重新走一遍代理方法,返回的url还是上一次的url
+- (void)requestFileSource { // 如果缓存中有,不会再次下载
+    
+    [MBProgressHUD ksShowHUDWithText:@"数据加载中......"];
+    NSArray *urlArray = [self.urlString containsString:@","] ? [self.urlString componentsSeparatedByString:@","] : @[self.urlString];
+    [KSRequestManager mutiDownloadFileRequest:urlArray progress:^(int64_t bytesRead, int64_t totalBytes) {
+        
+    } success:^(NSArray * _Nonnull dics) {
+        [MBProgressHUD ksHideHUD];
+        self.fileArray = [NSMutableArray arrayWithArray:dics];
+        [self.view addSubview:self.previewCtrl.view];
         [self.previewCtrl refreshCurrentPreviewItem];
         [self.previewCtrl refreshCurrentPreviewItem];
-    }
-    else { // 网络下载
-        self.hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-        [KSRequestManager downloadFileRequestWithFileUrl:self.urlString progress:^(int64_t bytesRead, int64_t totalBytes) {
-            
-        } success:^(NSURL * _Nonnull fileUrl) {
-             [self.hud hideAnimated:YES];
-            self.fileURL = fileUrl;
-            [self.view addSubview:self.previewCtrl.view];
-            [self.previewCtrl refreshCurrentPreviewItem];
-        } faliure:^(NSError * _Nonnull error) {
-             [self.hud hideAnimated:YES];
-        }];
-    }
+    } faliure:^(NSError * _Nonnull error) {
+        [MBProgressHUD ksHideHUD];
+    }];
 }
 }
 
 
 #pragma mark ------ QLPreviewControllerDataSource
 #pragma mark ------ QLPreviewControllerDataSource
 - (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
 - (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
-    return self.fileURL;
+    return self.fileArray[index];
 }
 }
 
 
 - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)previewController {
 - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)previewController {
-    return 1;
+    return self.fileArray.count;
 }
 }
 
 
 - (QLPreviewController *)previewCtrl {
 - (QLPreviewController *)previewCtrl {
@@ -77,55 +71,6 @@
     return _previewCtrl;
     return _previewCtrl;
 }
 }
 
 
-#pragma mark ----- 文件处理
-- (BOOL)saveFileWithFileName:(NSString *)fileName {
-    NSURL *preUrl = [self getSavePath:fileName];
-    NSString *copyPath = preUrl.path;
-    NSFileManager *fileMamager = [NSFileManager defaultManager];
-    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:@"FileLibrary"];
-    path = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",fileName]];
-    NSError *error = nil;
-    if (![fileMamager copyItemAtPath:copyPath toPath:path error:&error]) {
-        [fileMamager removeItemAtPath:copyPath error:nil];
-        NSLog(@"拷贝失败:%@", error.userInfo);
-        return NO;
-    }
-    else {
-        [fileMamager removeItemAtPath:copyPath error:nil];
-        return YES;
-    }
-}
-
-- (NSURL *)getSavePath:(NSString *)fileName {
-    //  在Documents目录下创建一个名为FileData的文件夹
-    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:@"FileLibrary"];
-    NSLog(@"%@",path);
-    
-    NSFileManager *fileManager = [NSFileManager defaultManager];
-    BOOL isDir = FALSE;
-    BOOL isDirExist = [fileManager fileExistsAtPath:path isDirectory:&isDir];
-    if(!(isDirExist && isDir)) {
-        BOOL bCreateDir = [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
-        if(!bCreateDir){
-            NSLog(@"创建文件夹失败!");
-        }
-        NSLog(@"创建文件夹成功,文件路径%@",path);
-    }
-    
-    path = [path stringByAppendingPathComponent:fileName];
-    NSLog(@"file path:%@",path);
-    NSURL *url=[NSURL fileURLWithPath:path];
-    return url;
-}
-
-//判断文件是否已经在沙盒中存在
--(BOOL)isFileExist:(NSString *)fileName {
-    NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:@"FileLibrary"];
-    NSString *filePath = [path stringByAppendingPathComponent:fileName];
-    NSFileManager *fileManager = [NSFileManager defaultManager];
-    BOOL result = [fileManager fileExistsAtPath:filePath];
-    return result;
-}
 /*
 /*
 #pragma mark - Navigation
 #pragma mark - Navigation
 
 

+ 8 - 0
MusicGradeExam/MusicGradeExam/酷乐秀.entitlements

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>aps-environment</key>
+	<string>development</string>
+</dict>
+</plist>