From aacae7954fa20748e4f9c666b46abda80a300d3f Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Thu, 7 Mar 2024 18:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=95=E9=9F=B3=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=92=AD=E6=94=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yinmeng-ios/Modules/Home/PlayVoiceManager.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/yinmeng-ios/Modules/Home/PlayVoiceManager.swift b/yinmeng-ios/Modules/Home/PlayVoiceManager.swift index 3b2d73f..b269df6 100644 --- a/yinmeng-ios/Modules/Home/PlayVoiceManager.swift +++ b/yinmeng-ios/Modules/Home/PlayVoiceManager.swift @@ -68,11 +68,12 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate { let downloadTask = session.downloadTask(with: request, completionHandler: { (location:URL?, response:URLResponse?, error:Error?) -> Void in - let locationPath = location!.path - if FileManager.default.fileExists(atPath: path){ - try? FileManager.default.removeItem(atPath: path) - } + guard let locationPath = location?.path else{return} + do { + if FileManager.default.fileExists(atPath: path){ + try FileManager.default.removeItem(atPath: path) + } // 文件移动至document try FileManager.default.copyItem(atPath: locationPath, toPath: path) // main @@ -80,15 +81,8 @@ class PlayVoiceManager: NSObject,AVAudioPlayerDelegate { self.beginPlayVoice(url:path) } } catch let error { - debugPrint(error) HUDTool.show(with: "\(error.localizedDescription)") } - // let data = NSData.init(contentsOfFile: locationPath) - // if let _data = data { - // let isHave = _data.write(toFile: path, atomically: true) - // print(isHave) - // self.beginPlayVoice(url:path) - // } })