質問編集履歴

2

エラー内容追加

2017/08/25 16:37

投稿

wint
wint

スコア13

test CHANGED
File without changes
test CHANGED
@@ -41,3 +41,9 @@
41
41
  FileManager.default.moveItem(atPath: original_path,toPath: copy_path) //コピー(すでにファイルが存在する場合にはコピーしないような処理はしてあります。)
42
42
 
43
43
  ```
44
+
45
+ エラーでは
46
+
47
+ couldn’t be moved because you don’t have permission to access “Documents”.
48
+
49
+ と表示されています。

1

コピーのパスの取得方法の詳細を追記

2017/08/25 16:37

投稿

wint
wint

スコア13

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,25 @@
19
19
  NSUnderlyingError=0x17e54930 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-802.0.53/src/swift/stdlib/public/core/ErrorType.swift, line 182
20
20
 
21
21
  ```
22
+
23
+
24
+
25
+ 追記:コピー部分の詳細(簡易)
26
+
27
+ ```swift
28
+
29
+ let document_dir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first //Documentのパス
30
+
31
+
32
+
33
+ let original_path = Bundle.main.path(forResource: "ファイル名", ofType: "拡張子") //コピー元のファイルのパス
34
+
35
+
36
+
37
+ copy_path = document_dir.append("/ファイル名.拡張子") //コピー先のパス
38
+
39
+
40
+
41
+ FileManager.default.moveItem(atPath: original_path,toPath: copy_path) //コピー(すでにファイルが存在する場合にはコピーしないような処理はしてあります。)
42
+
43
+ ```