Swift在do块中捕获多个错误

时间:2018-08-10 17:59:16

标签: ios swift swift4 nsfilemanager

为简单起见,我将多个try语句放在Swift的单个do块中,如下所示:

  do  {
         try fileManager.moveItem(atPath: originalPath, toPath: newPath)

         try fileManager.moveItem(atPath: thumbPath, toPath: newThumbPath)

   } catch {
               NSLog("Failed moving \(originalPath) to \(newPath)")           
   }

我的问题是我如何知道哪个try语句引发了异常以及如何在catch语句中正确识别和处理它?<​​/ p>

0 个答案:

没有答案