質問編集履歴

1

追加

2022/10/10 05:27

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -48,8 +48,9 @@
48
48
  //ファイルのパス
49
49
  let documentDirectoryURL = path
50
50
 
51
+ do {
51
52
  //アプリ内に保存
52
- try? data?.write(to: URL(fileURLWithPath: documentDirectoryURL))
53
+ try data?.write(to: URL(fileURLWithPath: documentDirectoryURL))
53
54
  print("documentDirectoryURLは")
54
55
  print(documentDirectoryURL)
55
56
 
@@ -64,6 +65,9 @@
64
65
  print("保存失敗! \(err) \(err?.localizedDescription)")
65
66
  }
66
67
  })
68
+ } catch {
69
+ print(error.localizedDescription)
70
+ }
67
71
  }
68
72
  }
69
73
  task.resume()
@@ -79,10 +83,20 @@
79
83
  /Users/apple/Library/Developer/CoreSimulator/Devices/AE..../data/Containers/Data/Application/98.../Documents
80
84
  ```
81
85
 
82
- ### 試したこと
86
+ ### 試したこと
83
87
 
84
88
  info.plstは設定済みです
85
89
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-10-09/c98d27eb-22df-4e95-8bb9-0f1e3516385a.png)
90
+
91
+ ### 試したこと②
92
+ do { try ...} catch {error.localizedDescription} 追記
93
+
94
+ ```
95
+ // 出力結果②
96
+
97
+ The file “Documents” couldn’t be saved in the folder "22-....-.....”.
98
+ ```
99
+
86
100
 
87
101
  ### 補足情報(FW/ツールのバージョンなど)
88
102