質問編集履歴
1
回答を受けてコードを修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
###前提・実現したいこと
|
2
2
|
|
3
3
|
labelに入力された言葉をファイル名にしてcsvファイルを作りたいのですがurlの部分の書き方が分かりません。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
###エラーメッセージ
|
8
|
+
|
9
|
+
```
|
10
|
+
|
11
|
+
Cannot convert value of type 'String' to expected argument type 'URL'
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
String interpolation produces a debug description for an optional value; did you mean to make this explicit?
|
16
|
+
|
17
|
+
```
|
4
18
|
|
5
19
|
|
6
20
|
|
@@ -14,15 +28,13 @@
|
|
14
28
|
|
15
29
|
|
16
30
|
|
17
|
-
let thePath = NSHomeDirectory()+"/Documents/(name.text).csv"
|
18
|
-
|
19
|
-
let textData = textView1.text
|
20
|
-
|
21
|
-
|
22
|
-
|
23
31
|
@IBAction func saveToFile(_ sender: Any) {
|
24
32
|
|
33
|
+
let thePath = NSHomeDirectory()+"/Documents/(name.text).csv"
|
34
|
+
|
35
|
+
let textData = textView1.text
|
36
|
+
|
25
|
-
do {
|
37
|
+
do {
|
26
38
|
|
27
39
|
try textData?.write(toFile: thePath, atomically: true, encoding: String.Encoding.utf8)
|
28
40
|
|
@@ -40,12 +52,4 @@
|
|
40
52
|
|
41
53
|
###試したこと
|
42
54
|
|
43
|
-
"/Documents/(name.text).csv"
|
44
|
-
|
45
|
-
"/Documents/"+(name.text)+".csv"
|
46
|
-
|
47
|
-
|
55
|
+
let dataname = name.textにしてみたりしたのですがエラーが直せません
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
など少しいじったり調べたりしたのですがよくわからないです、、
|