質問編集履歴

1

回答に従って書き換えてみました

2017/12/10 06:56

投稿

SKMT
SKMT

スコア57

test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,13 @@
8
8
 
9
9
  ```
10
10
 
11
+ コンパイルは通るが、シミュレータが動きません
12
+
11
- Cannot convert value of type 'FileManager' to expected argument type 'URL'
13
+ 2017-12-10 15:39:24.029120+0900 test [MC] Lazy loading NSBundle MobileCoreServices.framework
14
+
15
+ 2017-12-10 15:39:24.030068+0900 test [MC] Loaded MobileCoreServices.framework
16
+
17
+ 2017-12-10 15:39:24.044539+0900 test [MC] System group container for systemgroup.com.apple.configurationprofiles
12
18
 
13
19
  ```
14
20
 
@@ -38,8 +44,6 @@
38
44
 
39
45
  let fileManager = FileManager()
40
46
 
41
-
42
-
43
47
 
44
48
 
45
49
  override func viewDidLoad() {
@@ -48,7 +52,7 @@
48
52
 
49
53
  do {
50
54
 
51
- userPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
55
+ userPath = NSHomeDirectory()+"/Documents/sample.csv"
52
56
 
53
57
  var path = userPath
54
58
 
@@ -80,6 +84,8 @@
80
84
 
81
85
  let outputstr = data.joined(separator: "\n")
82
86
 
87
+ let saveFile = FileManager.default.urls(for: .documentDirectory,in: .userDomainMask).last?.appendingPathComponent("sample.csv")
88
+
83
89
 
84
90
 
85
91
  do {
@@ -90,7 +96,7 @@
90
96
 
91
97
  } else {
92
98
 
93
- try outputstr.write( to: fileManager, atomically: false, encoding: String.Encoding.utf8)
99
+ try outputstr.write( to: saveFile!, atomically: false, encoding: String.Encoding.utf8)
94
100
 
95
101
  }
96
102