質問編集履歴
4
削除の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,267 @@
|
|
1
|
+
###前提・実現したいこと
|
2
|
+
|
3
|
+
今カルタの文を読んでくれるアプリ?を作っています。今できているところは48種類のカルタの文をランダムに読んでくれるところです。しかし、一度読んだ文もまた繰り返されます。それを一度読んだものはもう読まないようにしたいです。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
ボタンを押すと次の文と最初の文字を表示しその文を
|
10
|
+
|
11
|
+
読み上げてくれるようになっています。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
###該当のソースコード
|
22
|
+
|
1
|
-
swift
|
23
|
+
```swift
|
24
|
+
|
2
|
-
|
25
|
+
import UIKit
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
import AVFoundation
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
class ViewController: UIViewController {
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
@IBOutlet weak var QuestionLabel: UILabel!
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
@IBOutlet weak var Button1: UIButton!
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
@IBOutlet weak var Next: UIButton!
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
var CorrectAnswer = String\(\)
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
override func viewDidLoad\(\) {
|
54
|
+
|
55
|
+
super\.viewDidLoad\(\)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Hide\(\)
|
60
|
+
|
61
|
+
RandomQuestions\(\)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
override func didReceiveMemoryWarning\(\) {
|
70
|
+
|
71
|
+
super\.didReceiveMemoryWarning\(\)
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
}
|
76
|
+
|
3
|
-
fui
|
77
|
+
func RandomQuestions\(\){
|
78
|
+
|
79
|
+
|
80
|
+
|
4
|
-
|
81
|
+
var RandomNumber = arc4random\(\) % 48
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
RandomNumber \+= 1
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
switch \(RandomNumber\) {
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
case 1:
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
QuestionLabel\.text = "モンゴルの民族模様は自由の印"
|
98
|
+
|
99
|
+
Button1\.setTitle\("も", for: \.normal\)
|
100
|
+
|
101
|
+
//文を読む
|
102
|
+
|
103
|
+
let synthesizer = AVSpeechSynthesizer\(\)
|
104
|
+
|
105
|
+
let utterance = AVSpeechUtterance\(string: "モンゴルの民族模様は自由の印。"\)
|
106
|
+
|
107
|
+
synthesizer\.speak\(utterance\)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
break
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
case 2:
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
QuestionLabel\.text = "三色の統一ドイツ黒赤金"
|
120
|
+
|
121
|
+
Button1\.setTitle\("さ", for: \.normal\)
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
let synthesizer = AVSpeechSynthesizer\(\)
|
126
|
+
|
127
|
+
let utterance = AVSpeechUtterance\(string: "三色の統一ドイツ黒赤金"\)
|
128
|
+
|
129
|
+
synthesizer\.speak\(utterance\)
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
break
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
case 3:
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
QuestionLabel\.text = "エクアドルコンドルが飛ぶアンデスへ"
|
148
|
+
|
149
|
+
Button1\.setTitle\("え", for: \.normal\)
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
let synthesizer = AVSpeechSynthesizer\(\)
|
154
|
+
|
155
|
+
let utterance = AVSpeechUtterance\(string: "エクアドルコンドルが飛ぶアンデスへ"\)
|
156
|
+
|
157
|
+
synthesizer\.speak\(utterance\)
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
break
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
//略
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
case 48:
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
QuestionLabel\.text = "バーレーンはギザギザ模様で鮮やかに"
|
182
|
+
|
183
|
+
Button1\.setTitle\("ば", for: \.normal\)
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
let synthesizer = AVSpeechSynthesizer\(\)
|
188
|
+
|
189
|
+
let utterance = AVSpeechUtterance\(string: "バーレーンはギザギザ模様で鮮やかに"\)
|
190
|
+
|
191
|
+
synthesizer\.speak\(utterance\)
|
192
|
+
|
193
|
+
break
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
default:
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
break
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
func Hide\(\){
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
Next\.isHidden = true
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
func UnHide\(\){
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
Next\.isHidden = false
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
@IBAction func Button1Action\(_ sender: AnyObject\) {
|
234
|
+
|
235
|
+
|
236
|
+
|
5
|
-
|
237
|
+
UnHide\(\)
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
@IBAction func Next\(_ sender: AnyObject\) {
|
246
|
+
|
247
|
+
RandomQuestions\(\)
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
```
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
###試したこと
|
266
|
+
|
267
|
+
nsuser defaultsを使ったり、空の配列を作り一度つかったものを入れたりなどと案は思いつきますが、どのようにコードを書くのかわかりません。
|
3
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,267 +1,5 @@
|
|
1
|
-
|
1
|
+
swift
|
2
2
|
|
3
|
-
|
3
|
+
fuiiyiioggggggggggggスィft
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
ボタンを押すと次の文と最初の文字を表示しその文を
|
10
|
-
|
11
|
-
読み上げてくれるようになっています。
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
5
|
+
スィft」えっっっっw
|
22
|
-
|
23
|
-
```swift
|
24
|
-
|
25
|
-
import UIKit
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
import AVFoundation
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
class ViewController: UIViewController {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@IBOutlet weak var QuestionLabel: UILabel!
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@IBOutlet weak var Button1: UIButton!
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@IBOutlet weak var Next: UIButton!
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
var CorrectAnswer = String()
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
override func viewDidLoad() {
|
54
|
-
|
55
|
-
super.viewDidLoad()
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
Hide()
|
60
|
-
|
61
|
-
RandomQuestions()
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
override func didReceiveMemoryWarning() {
|
70
|
-
|
71
|
-
super.didReceiveMemoryWarning()
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
func RandomQuestions(){
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
var RandomNumber = arc4random() % 48
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
RandomNumber += 1
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
switch (RandomNumber) {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
case 1:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
QuestionLabel.text = "モンゴルの民族模様は自由の印"
|
98
|
-
|
99
|
-
Button1.setTitle("も", for: .normal)
|
100
|
-
|
101
|
-
//文を読む
|
102
|
-
|
103
|
-
let synthesizer = AVSpeechSynthesizer()
|
104
|
-
|
105
|
-
let utterance = AVSpeechUtterance(string: "モンゴルの民族模様は自由の印。")
|
106
|
-
|
107
|
-
synthesizer.speak(utterance)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
break
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
case 2:
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
QuestionLabel.text = "三色の統一ドイツ黒赤金"
|
120
|
-
|
121
|
-
Button1.setTitle("さ", for: .normal)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
let synthesizer = AVSpeechSynthesizer()
|
126
|
-
|
127
|
-
let utterance = AVSpeechUtterance(string: "三色の統一ドイツ黒赤金")
|
128
|
-
|
129
|
-
synthesizer.speak(utterance)
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
break
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
case 3:
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
QuestionLabel.text = "エクアドルコンドルが飛ぶアンデスへ"
|
148
|
-
|
149
|
-
Button1.setTitle("え", for: .normal)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
let synthesizer = AVSpeechSynthesizer()
|
154
|
-
|
155
|
-
let utterance = AVSpeechUtterance(string: "エクアドルコンドルが飛ぶアンデスへ")
|
156
|
-
|
157
|
-
synthesizer.speak(utterance)
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
break
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
//略
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
case 48:
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
QuestionLabel.text = "バーレーンはギザギザ模様で鮮やかに"
|
182
|
-
|
183
|
-
Button1.setTitle("ば", for: .normal)
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
let synthesizer = AVSpeechSynthesizer()
|
188
|
-
|
189
|
-
let utterance = AVSpeechUtterance(string: "バーレーンはギザギザ模様で鮮やかに")
|
190
|
-
|
191
|
-
synthesizer.speak(utterance)
|
192
|
-
|
193
|
-
break
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
default:
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
break
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
func Hide(){
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
Next.isHidden = true
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
func UnHide(){
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
Next.isHidden = false
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
@IBAction func Button1Action(_ sender: AnyObject) {
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
UnHide()
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
@IBAction func Next(_ sender: AnyObject) {
|
246
|
-
|
247
|
-
RandomQuestions()
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
```
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
###試したこと
|
266
|
-
|
267
|
-
nsuser defaultsを使ったり、空の配列を作り一度つかったものを入れたりなどと案は思いつきますが、どのようにコードを書くのかわかりません。
|
2
コードを直しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -124,7 +124,7 @@
|
|
124
124
|
|
125
125
|
let synthesizer = AVSpeechSynthesizer()
|
126
126
|
|
127
|
-
let utterance = AVSpeechUtterance(string: "
|
127
|
+
let utterance = AVSpeechUtterance(string: "三色の統一ドイツ黒赤金")
|
128
128
|
|
129
129
|
synthesizer.speak(utterance)
|
130
130
|
|
1
コードを増やしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,57 @@
|
|
22
22
|
|
23
23
|
```swift
|
24
24
|
|
25
|
-
|
25
|
+
import UIKit
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
import AVFoundation
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
class ViewController: UIViewController {
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
@IBOutlet weak var QuestionLabel: UILabel!
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
@IBOutlet weak var Button1: UIButton!
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
@IBOutlet weak var Next: UIButton!
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
var CorrectAnswer = String()
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
override func viewDidLoad() {
|
54
|
+
|
55
|
+
super.viewDidLoad()
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Hide()
|
60
|
+
|
61
|
+
RandomQuestions()
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
override func didReceiveMemoryWarning() {
|
70
|
+
|
71
|
+
super.didReceiveMemoryWarning()
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
}
|
26
76
|
|
27
77
|
func RandomQuestions(){
|
28
78
|
|
@@ -154,7 +204,53 @@
|
|
154
204
|
|
155
205
|
}
|
156
206
|
|
207
|
+
|
208
|
+
|
157
|
-
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
func Hide(){
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
Next.isHidden = true
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
func UnHide(){
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
Next.isHidden = false
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
@IBAction func Button1Action(_ sender: AnyObject) {
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
UnHide()
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
@IBAction func Next(_ sender: AnyObject) {
|
246
|
+
|
247
|
+
RandomQuestions()
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
}
|
158
254
|
|
159
255
|
|
160
256
|
|