comparison GeoQuiz/Logic/GameProtocol+Extension.swift @ 19:f140bb277c96

refactor code
author Dennis C. M. <dennis@denniscm.com>
date Sun, 23 Oct 2022 00:11:38 +0100
parents f1967f8cc67b
children e281791e0494
comparison
equal deleted inserted replaced
18:d20cf93c9812 19:f140bb277c96
60 60
61 selector() 61 selector()
62 } 62 }
63 63
64 func answer(_ choice: (key: String, value: T), selector: () -> Void) { 64 func answer(_ choice: (key: String, value: T), selector: () -> Void) {
65 let haptics = Haptics() 65 let haptics = HapticsController()
66 66
67 if correctAnswer == choice { 67 if correctAnswer == choice {
68 haptics.success() 68 haptics.success()
69 playSound("correctAnswer") 69 playSound("correctAnswer")
70 70
123 print("Couldn't save object to CoreData: \(error)") 123 print("Couldn't save object to CoreData: \(error)")
124 } 124 }
125 } 125 }
126 126
127 private func playSound(_ filename: String) { 127 private func playSound(_ filename: String) {
128 let user = User() 128 let user = UserController()
129 129
130 if user.data.sound { 130 if user.data.sound {
131 guard let soundFileURL = Bundle.main.url(forResource: filename, withExtension: "wav") else { 131 guard let soundFileURL = Bundle.main.url(forResource: filename, withExtension: "wav") else {
132 fatalError("Sound file \(filename) couldn't be found") 132 fatalError("Sound file \(filename) couldn't be found")
133 } 133 }