1. 程式人生 > >ios自動更新(一)

ios自動更新(一)

// 開始下載,檔名會自動去取url的檔名NSURLRequest *request = [NSURLRequestrequestWithURL:[NSURLURLWithString:versionRecord.downurl] cachePolicy:NSURLRequestReloadIgnoringCacheDatatimeoutInterval:60];AFDownloadRequestOperation *operation = [[AFDownloadRequestOperationalloc] initWithRequest:request targetPath:targetFullPath
shouldResume:YES];            operation.shouldOverwrite = YES;            [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation * _Nonnull operation, id_Nonnull responseObject) {// 下載成功才更新索引資料庫                [[selfclass] updateIndexDB:versionRecord];DLog(@"update file \"%@/%@\" from version %ld to version %ld"
,versionRecord.filepath, versionRecord.filename, version, versionRecord.versionno);            } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {DLog(@"download resource(%@) error: %@",  operation.request.URL.absoluteString, error.localizedDescription);            }];