File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
bk2ch10p526textFieldDelegate/ch23p810textFieldDelegate Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -18,24 +18,17 @@ class MyTextField: UITextField {
18
18
19
19
20
20
override func canPerformAction( action: Selector , withSender sender: AnyObject ? ) -> Bool {
21
- if action == " expand: " {
22
- if let r = self . selectedTextRange {
23
- if let s = self . textInRange ( r) {
24
- return s. characters. count == 2
25
- && self . stateForAbbrev ( s) != nil
26
- }
27
- }
21
+ if action == " expand: " , let r = self . selectedTextRange,
22
+ let s = self . textInRange ( r) {
23
+ return s. characters. count == 2 && self . stateForAbbrev ( s) != nil
28
24
}
29
25
return super. canPerformAction ( action, withSender: sender)
30
26
}
31
27
32
28
func expand( sender: AnyObject ? ) {
33
- if let r = self . selectedTextRange {
34
- if let s = self . textInRange ( r) {
35
- if let ss = self . stateForAbbrev ( s) {
36
- self . replaceRange ( r, withText: ss)
37
- }
38
- }
29
+ if let r = self . selectedTextRange, let s = self . textInRange ( r) ,
30
+ let ss = self . stateForAbbrev ( s) {
31
+ self . replaceRange ( r, withText: ss)
39
32
}
40
33
}
41
34
You can’t perform that action at this time.
0 commit comments