@@ -11,8 +11,26 @@ import RxSwift
11
11
import RxCocoa
12
12
import CoreLocation
13
13
14
+ extension UILabel {
15
+ public override var accessibilityValue : String ! {
16
+ get {
17
+ return self . text
18
+ }
19
+ set {
20
+ self . text = newValue
21
+ self . accessibilityValue = newValue
22
+ }
23
+ }
24
+ }
25
+
14
26
class APIWrappersViewController : ViewController {
15
27
28
+ @IBOutlet weak var debugLabel : UILabel !
29
+
30
+ @IBOutlet weak var openActionSheet : UIButton !
31
+
32
+ @IBOutlet weak var openAlertView : UIButton !
33
+
16
34
@IBOutlet weak var bbitem : UIBarButtonItem !
17
35
18
36
@IBOutlet weak var segmentedControl : UISegmentedControl !
@@ -32,130 +50,142 @@ class APIWrappersViewController: ViewController {
32
50
let disposeBag = DisposeBag ( )
33
51
34
52
let manager = CLLocationManager ( )
35
-
53
+
36
54
override func viewDidLoad( ) {
37
55
super. viewDidLoad ( )
38
56
57
+ datePicker. date = NSDate ( timeIntervalSince1970: 0 )
58
+
39
59
let ash = UIActionSheet ( title: " Title " , delegate: nil , cancelButtonTitle: " Cancel " , destructiveButtonTitle: " OK " )
40
60
let av = UIAlertView ( title: " Title " , message: " The message " , delegate: nil , cancelButtonTitle: " Cancel " , otherButtonTitles: " OK " , " Two " , " Three " , " Four " , " Five " )
41
61
62
+ openActionSheet. rx_tap
63
+ >- subscribeNext { x in
64
+ ash. showInView ( self . view)
65
+ }
66
+ >- disposeBag. addDisposable
67
+
68
+ openAlertView. rx_tap
69
+ >- subscribeNext { x in
70
+ av. show ( )
71
+ }
72
+ >- disposeBag. addDisposable
73
+
42
74
// MARK: UIActionSheet
43
75
44
76
ash. rx_clickedButtonAtIndex
45
- >- subscribeNext { x in
46
- println ( " UIActionSheet clickedButtonAtIndex \( x) " )
77
+ >- subscribeNext { [ weak self ] x in
78
+ self ? . debug ( " UIActionSheet clickedButtonAtIndex \( x) " )
47
79
}
48
80
>- disposeBag. addDisposable
49
81
50
82
ash. rx_willDismissWithButtonIndex
51
- >- subscribeNext { x in
52
- println ( " UIActionSheet willDismissWithButtonIndex \( x) " )
83
+ >- subscribeNext { [ weak self ] x in
84
+ self ? . debug ( " UIActionSheet willDismissWithButtonIndex \( x) " )
53
85
}
54
86
>- disposeBag. addDisposable
55
87
56
88
ash. rx_didDismissWithButtonIndex
57
- >- subscribeNext { x in
58
- println ( " UIActionSheet didDismissWithButtonIndex \( x) " )
59
-
60
- av. show ( )
89
+ >- subscribeNext { [ weak self] x in
90
+ self ? . debug ( " UIActionSheet didDismissWithButtonIndex \( x) " )
61
91
}
62
92
>- disposeBag. addDisposable
63
93
64
94
65
95
// MARK: UIAlertView
66
96
67
97
av. rx_clickedButtonAtIndex
68
- >- subscribeNext { x in
69
- println ( " UIAlertView clickedButtonAtIndex \( x) " )
98
+ >- subscribeNext { [ weak self ] x in
99
+ self ? . debug ( " UIAlertView clickedButtonAtIndex \( x) " )
70
100
}
71
101
>- disposeBag. addDisposable
72
102
73
103
av. rx_willDismissWithButtonIndex
74
- >- subscribeNext { x in
75
- println ( " UIAlertView willDismissWithButtonIndex \( x) " )
104
+ >- subscribeNext { [ weak self ] x in
105
+ self ? . debug ( " UIAlertView willDismissWithButtonIndex \( x) " )
76
106
}
77
107
>- disposeBag. addDisposable
78
108
79
109
av. rx_didDismissWithButtonIndex
80
- >- subscribeNext { x in
81
- println ( " UIAlertView didDismissWithButtonIndex \( x) " )
110
+ >- subscribeNext { [ weak self ] x in
111
+ self ? . debug ( " UIAlertView didDismissWithButtonIndex \( x) " )
82
112
}
83
113
>- disposeBag. addDisposable
84
114
85
115
86
116
87
117
88
- ash . showInView ( view )
118
+
89
119
90
120
91
121
// MARK: UIBarButtonItem
92
122
93
123
bbitem. rx_tap
94
- >- subscribeNext { x in
95
- println ( " UIBarButtonItem Tapped " )
124
+ >- subscribeNext { [ weak self ] x in
125
+ self ? . debug ( " UIBarButtonItem Tapped " )
96
126
}
97
127
>- disposeBag. addDisposable
98
128
99
129
// MARK: UISegmentedControl
100
130
101
131
segmentedControl. rx_value
102
- >- subscribeNext { x in
103
- println ( " UISegmentedControl value \( x) " )
132
+ >- subscribeNext { [ weak self ] x in
133
+ self ? . debug ( " UISegmentedControl value \( x) " )
104
134
}
105
135
>- disposeBag. addDisposable
106
136
107
137
108
138
// MARK: UISwitch
109
139
110
140
switcher. rx_value
111
- >- subscribeNext { x in
112
- println ( " UISwitch value \( x) " )
141
+ >- subscribeNext { [ weak self ] x in
142
+ self ? . debug ( " UISwitch value \( x) " )
113
143
}
114
144
>- disposeBag. addDisposable
115
145
116
146
117
147
// MARK: UIButton
118
148
119
149
button. rx_tap
120
- >- subscribeNext { x in
121
- println ( " UIButton Tapped " )
150
+ >- subscribeNext { [ weak self ] x in
151
+ self ? . debug ( " UIButton Tapped " )
122
152
}
123
153
>- disposeBag. addDisposable
124
154
125
155
126
156
// MARK: UISlider
127
157
128
158
slider. rx_value
129
- >- subscribeNext { x in
130
- println ( " UISlider value \( x) " )
159
+ >- subscribeNext { [ weak self ] x in
160
+ self ? . debug ( " UISlider value \( x) " )
131
161
}
132
162
>- disposeBag. addDisposable
133
163
134
164
135
165
// MARK: UIDatePicker
136
166
137
167
datePicker. rx_date
138
- >- subscribeNext { x in
139
- println ( " UIDatePicker date \( x) " )
168
+ >- subscribeNext { [ weak self ] x in
169
+ self ? . debug ( " UIDatePicker date \( x) " )
140
170
}
141
171
>- disposeBag. addDisposable
142
172
143
173
144
174
// MARK: UITextField
145
175
146
176
textField. rx_text
147
- >- subscribeNext { [ unowned self] x in
148
- println ( " UITextField text \( x) " )
149
- self . textField. resignFirstResponder ( )
177
+ >- subscribeNext { [ weak self] x in
178
+ self ? . debug ( " UITextField text \( x) " )
179
+ self ? . textField. resignFirstResponder ( )
150
180
}
151
181
>- disposeBag. addDisposable
152
182
153
183
154
184
// MARK: UIGestureRecognizer
155
185
156
186
mypan. rx_event
157
- >- subscribeNext { x in
158
- println ( " UIGestureRecognizer event \( x) " )
187
+ >- subscribeNext { [ weak self ] x in
188
+ self ? . debug ( " UIGestureRecognizer event \( x. state ) " )
159
189
}
160
190
>- disposeBag. addDisposable
161
191
@@ -166,22 +196,27 @@ class APIWrappersViewController: ViewController {
166
196
manager. requestWhenInUseAuthorization ( )
167
197
168
198
manager. rx_didUpdateLocations
169
- >- subscribeNext { x in
170
- println ( " rx_didUpdateLocations \( x) " )
199
+ >- subscribeNext { [ weak self ] x in
200
+ self ? . debug ( " rx_didUpdateLocations \( x) " )
171
201
}
172
202
>- disposeBag. addDisposable
173
203
174
204
manager. rx_didFailWithError
175
- >- subscribeNext { x in
176
- println ( " rx_didFailWithError \( x) " )
205
+ >- subscribeNext { [ weak self ] x in
206
+ self ? . debug ( " rx_didFailWithError \( x) " )
177
207
}
178
208
>- disposeBag. addDisposable
179
-
209
+
180
210
181
211
manager. startUpdatingLocation ( )
182
212
213
+
214
+
215
+ }
216
+
217
+ func debug( string: String ) {
218
+ println ( string)
219
+ debugLabel. text = string
183
220
}
184
-
185
-
186
221
}
187
222
0 commit comments