質問編集履歴

1

コードとエラーメッセージを追記しました

2019/07/23 07:39

投稿

hodoru3sei
hodoru3sei

スコア284

test CHANGED
File without changes
test CHANGED
@@ -6,10 +6,46 @@
6
6
 
7
7
  ### 試したこと
8
8
 
9
- 画像の様にFile's OrnerのクラスにViewControllerを設定しました。
9
+ 画像の様にFile's OwnerのクラスにViewControllerを設定しました。
10
10
 
11
11
  しかしこの状態だと紐付けたUISwitchの要素にアクセスしようとするとoptionalでクラッシュしてしまいます。
12
12
 
13
13
  ![イメージ説明](7bdc677e94fbd051183882300099fc09.png)
14
14
 
15
- File's Orner以外で何か設定が必要なのでしょうか?
15
+ File's Owner以外で何か設定が必要なのでしょうか?
16
+
17
+
18
+
19
+
20
+
21
+ ###追記
22
+
23
+ UISwitchを繋いでいる部分です。
24
+
25
+ ```Swift
26
+
27
+ @IBOutlet weak var mySwitch: UISwitch!
28
+
29
+ override func viewDidLoad() {
30
+
31
+ super.viewDidLoad()
32
+
33
+ // Do any additional setup after loading the view.
34
+
35
+ mySwitch.backgroundColor = .red
36
+
37
+ }
38
+
39
+ ```
40
+
41
+
42
+
43
+ エラーメッセージは以下の様に表示されます
44
+
45
+ ```
46
+
47
+ Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
48
+
49
+ 2019-07-23 16:39:04.377294+0900 Xib test[12466:728503] Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
50
+
51
+ ```