-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSurvey2ViewController.swift
More file actions
69 lines (57 loc) · 1.97 KB
/
Copy pathSurvey2ViewController.swift
File metadata and controls
69 lines (57 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Survey2Controller.swift
// CRC_iOS
//
// Created by 우예지 on 2021/05/11.
//
import UIKit
import AudioToolbox
class survey2ViewController: UIViewController {
let ad = UIApplication.shared.delegate as? AppDelegate
let fileCreator = FileCreator()
var isEnd: Bool = false
// onClick
@IBAction func onClick2(_ sender: Any) {
if index != nil {
_ = chosenIndex?(self.index!)
// create file
let fileURL = fileCreator.createFileURL(transportation: ad!.selectedTransportation, sensor: "Survey", directoryURL: (ad?.directoryURL)!)
fileCreator.writeInFile(csvString: "Survey3\n" + resultArray[self.index!], fileURL: fileURL)
// close the app by exit
exit(1)
}
}
// Radio Buttons
@IBOutlet var resultButtons: [UIButton]!
let resultArray: [String] = ["Yes", "No"]
var index: Int?
var chosenIndex: ((Int) -> (Int))?
@IBAction func resultButtonSelect(_ sender: UIButton) {
if (index != nil || !sender.isSelected) {
for index in resultButtons.indices {
resultButtons[index].isSelected = false
}
sender.isSelected = true
index = resultButtons.firstIndex(of: sender)
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
for _ in 0..<10 {
AudioServicesPlaySystemSound(4095)
AudioServicesPlaySystemSound(1234)
if isEnd == true {
break
}
}
// end alert
let endAlert = UIAlertController(title: "측정 완료", message: "🔔", preferredStyle: UIAlertController.Style.alert)
let okAction = UIAlertAction(title: "확인", style: .default) { (action) in
self.isEnd = true
}
endAlert.addAction(okAction)
present(endAlert, animated: false, completion: nil)
}
}