質問編集履歴
1
回答に従って書き換えてみました
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,7 +3,10 @@
|
|
3
3
|
|
4
4
|
###発生している問題・エラーメッセージ
|
5
5
|
```
|
6
|
+
コンパイルは通るが、シミュレータが動きません
|
6
|
-
|
7
|
+
2017-12-10 15:39:24.029120+0900 test [MC] Lazy loading NSBundle MobileCoreServices.framework
|
8
|
+
2017-12-10 15:39:24.030068+0900 test [MC] Loaded MobileCoreServices.framework
|
9
|
+
2017-12-10 15:39:24.044539+0900 test [MC] System group container for systemgroup.com.apple.configurationprofiles
|
7
10
|
```
|
8
11
|
と表示されているのですがどう変えていいか分かりません
|
9
12
|
|
@@ -18,12 +21,11 @@
|
|
18
21
|
var data:[String] = []
|
19
22
|
var userPath:String!
|
20
23
|
let fileManager = FileManager()
|
21
|
-
|
22
24
|
|
23
25
|
override func viewDidLoad() {
|
24
26
|
super.viewDidLoad()
|
25
27
|
do {
|
26
|
-
userPath =
|
28
|
+
userPath = NSHomeDirectory()+"/Documents/sample.csv"
|
27
29
|
var path = userPath
|
28
30
|
if (fileManager.fileExists(atPath: path!) == false) {
|
29
31
|
path = Bundle.main.path(forResource: "sample", ofType: "csv")!
|
@@ -39,12 +41,13 @@
|
|
39
41
|
|
40
42
|
func saveCSV() {
|
41
43
|
let outputstr = data.joined(separator: "\n")
|
44
|
+
let saveFile = FileManager.default.urls(for: .documentDirectory,in: .userDomainMask).last?.appendingPathComponent("sample.csv")
|
42
45
|
|
43
46
|
do {
|
44
47
|
if(outputstr == "") {
|
45
48
|
try fileManager.removeItem(atPath: userPath)
|
46
49
|
} else {
|
47
|
-
try outputstr.write( to:
|
50
|
+
try outputstr.write( to: saveFile!, atomically: false, encoding: String.Encoding.utf8)
|
48
51
|
}
|
49
52
|
} catch {
|
50
53
|
print(error)
|