質問編集履歴

2

変数変更

2022/04/02 05:32

投稿

reoreo
reoreo

スコア0

test CHANGED
File without changes
test CHANGED
@@ -24,12 +24,11 @@
24
24
  変更後
25
25
 
26
26
  ```swift
27
- private let unntiSound: AVAudioPlayer? = try! AVAudioPlayer(data: NSDataAsset(name: "sound")!.data)
27
+ private let Sound: AVAudioPlayer? = try! AVAudioPlayer(data: NSDataAsset(name: "sound")!.data)
28
28
 
29
- //追加③ ②のkirakiraSoundを再生するメソッドを作成
30
29
  private func playSound(){
31
- if unntiSound != nil {
30
+ if Sound != nil {
32
- unntiSound?.play()
31
+ Sound?.play()
33
32
 
34
33
  }
35
34
 

1

Optional型に関する変更後のコードを追加しました。

2022/04/02 05:29

投稿

reoreo
reoreo

スコア0

test CHANGED
File without changes
test CHANGED
@@ -20,3 +20,18 @@
20
20
 
21
21
  修正がありましたら追って追記します。
22
22
  初歩的な話かと思いますが、何卒よろしくお願いいたします。
23
+
24
+ 変更後
25
+
26
+ ```swift
27
+ private let unntiSound: AVAudioPlayer? = try! AVAudioPlayer(data: NSDataAsset(name: "sound")!.data)
28
+
29
+ //追加③ ②のkirakiraSoundを再生するメソッドを作成
30
+ private func playSound(){
31
+ if unntiSound != nil {
32
+ unntiSound?.play()
33
+
34
+ }
35
+
36
+ }
37
+ ```