回答編集履歴

1

修正

2016/07/17 12:17

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -15,3 +15,91 @@
15
15
 
16
16
 
17
17
  ロジック自体はインスタンスを渡せばちゃんと判定できています、このメソッドを使用したい状態とはどのような時でしょうか?
18
+
19
+
20
+
21
+
22
+
23
+ アドレスが同じと確認したコード
24
+
25
+ ---
26
+
27
+ ```swift
28
+
29
+ import UIKit
30
+
31
+
32
+
33
+ class ViewController1: UIViewController {
34
+
35
+
36
+
37
+ override func viewDidLoad() {
38
+
39
+ super.viewDidLoad()
40
+
41
+ }
42
+
43
+
44
+
45
+ @IBAction func pushNextButton(sender: UIButton) {
46
+
47
+
48
+
49
+ let nextStoryboard = UIStoryboard(name: "Main2", bundle: nil)
50
+
51
+ let vc2 = nextStoryboard.instantiateInitialViewController() as! ViewController2
52
+
53
+ vc2.myStoryboard = nextStoryboard
54
+
55
+ self.navigationController?.pushViewController(vc2, animated: true)
56
+
57
+ }
58
+
59
+ }
60
+
61
+
62
+
63
+
64
+
65
+ class ViewController2: UIViewController {
66
+
67
+
68
+
69
+ var myStoryboard: UIStoryboard!
70
+
71
+
72
+
73
+ override func viewDidLoad() {
74
+
75
+ super.viewDidLoad()
76
+
77
+
78
+
79
+ receive(self)
80
+
81
+ }
82
+
83
+
84
+
85
+ func receive(vc: UIViewController) {
86
+
87
+
88
+
89
+ if vc.storyboard === myStoryboard {
90
+
91
+ print("同じ")
92
+
93
+ //=> 同じ
94
+
95
+ } else {
96
+
97
+ print("違う")
98
+
99
+ }
100
+
101
+ }
102
+
103
+ }
104
+
105
+ ```